Created
May 26, 2019 21:45
-
-
Save rohan-deshpande/7086c4f18cd3ce44fff29b00e351d94a to your computer and use it in GitHub Desktop.
NGINX config for a node-restify API and public website running via Laravel Forge
This file contains 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
# NOTE: Replace forge.site.com with your site domain, a lot of this stuff will be auto generated by forge. | |
# FORGE CONFIG (DO NOT REMOVE!) | |
include forge-conf/forge.site.com/before/*; | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name forge.site.com; | |
root /home/forge/forge.site.com/; | |
# FORGE SSL (DO NOT REMOVE!) | |
ssl_certificate /etc/nginx/ssl/forge.site.com/345652/server.crt; | |
ssl_certificate_key /etc/nginx/ssl/forge.site.com/345652/server.key; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
ssl_ciphers 'AUTOGENERATED_KEY'; | |
ssl_prefer_server_ciphers on; | |
ssl_dhparam /etc/nginx/dhparams.pem; | |
add_header X-Frame-Options "SAMEORIGIN"; | |
add_header X-XSS-Protection "1; mode=block"; | |
add_header X-Content-Type-Options "nosniff"; | |
index index.html index.htm index.php; | |
charset utf-8; | |
# FORGE CONFIG (DO NOT REMOVE!) | |
include forge-conf/forge.site.com/server/*; | |
# WEB LOCATION | |
location / { | |
root /home/forge/forge.site.com/src/build/; | |
try_files $uri /index.html; | |
auth_basic "Restricted Content"; | |
auth_basic_user_file /etc/nginx/.htpasswd; | |
} | |
# API LOCATION | |
location /api { | |
rewrite ^/api(.*) $1 break; | |
proxy_pass http://localhost:3001; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_cache_bypass $http_upgrade; | |
} | |
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 /var/log/nginx/forge.site.com-error.log error; | |
error_page 404 /index.php; | |
location ~ \.php$ { | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
} | |
location ~ /\.(?!well-known).* { | |
deny all; | |
} | |
} | |
# FORGE CONFIG (DO NOT REMOVE!) | |
include forge-conf/forge.site.com/after/*; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment