Last active
March 25, 2021 22:04
-
-
Save danieladarve/d733bde89988bfba918ff5b3bf4862d9 to your computer and use it in GitHub Desktop.
nginx-server-template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 127.0.0.1:80; | |
listen [::]:443 ssl http2; | |
server_name <your_website>.test www.<your_website>.test *.<your_website>.test; | |
return 301 https://$host$request_uri; | |
} | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name <your_website>.test www.<your_website>.test *.<your_website>.test; | |
root /; # path to your app | |
index index.php index.html index.htm; | |
charset utf-8; | |
client_max_body_size 512M; | |
http2_push_preload on; | |
location / { | |
internal; | |
alias /; | |
# CORS Rules # | |
add_header Access-Control-Allow-Origin *; | |
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, OPTIONS, DELETE'; | |
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Authorization'; | |
# END of CORS Rules # | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
ssl_certificate "/opt/homebrew/etc/nginx/ssl/<your_website>.crt"; | |
ssl_certificate_key "/opt/homebrew/etc/nginx/ssl/<your_website>.key"; | |
location = /favicon.ico { access_log off; log_not_found off; } | |
location = /robots.txt { access_log off; log_not_found off; } | |
access_log off; | |
error_log "/opt/homebrew/var/log/nginx/<your_website>-error.log"; | |
error_page 404 /index.php; | |
location ~ [^/]\.php(/|$) { | |
# CORS Rules | |
add_header Access-Control-Allow-Origin *; | |
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, OPTIONS, DELETE'; | |
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Authorization'; | |
# END of CORS Rules # | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass 127.0.0.1:9074; #PORTS:> [email protected] 9000 [email protected] 9001 [email protected] 9002 [email protected] 9004 | |
fastcgi_index index.php; | |
include fastcgi_params; | |
} | |
location ~ /\.(?!well-known).* { | |
deny all; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment