Last active
November 7, 2022 19:11
-
-
Save micheleberardi/8b97d9a55cef4addc56bcded82e44e48 to your computer and use it in GitHub Desktop.
nginx conf for nextJS
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
server { | |
listen 80; | |
server_name sb.domain.com; | |
return 301 https://sb.domain.com$request_uri; | |
} | |
server { | |
listen 443 ssl http2; | |
server_name sb.domain.com; | |
#root /var/www/html/source/sb.domain.com; | |
index index.html index.json; | |
#auth_basic "Restricted Area"; | |
#auth_basic_user_file /etc/nginx/auth.d/.htpasswd; | |
# SSL parameters | |
ssl_certificate /etc/ssl/certs/STAR.sb.domain.com.pem; | |
ssl_certificate_key /etc/ssl/certs/STAR.sb.domain.com.pem; | |
ssl_trusted_certificate /etc/ssl/certs/STAR.sb.domain.com.pem; | |
ssl_protocols TLSv1.2; | |
add_header 'Access-Control-Allow-Origin' "*"; | |
# log files | |
access_log /var/log/nginx/sb.domain.com.access.log; | |
error_log /var/log/nginx/sb.domain.com.error.log; | |
# GZIP | |
gzip on; | |
gzip_disable "msie6"; | |
gzip_vary on; | |
gzip_proxied any; | |
gzip_comp_level 6; | |
gzip_buffers 16 8k; | |
gzip_http_version 1.1; | |
gzip_min_length 0; | |
gzip_types text/plain application/javascript text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype; | |
location ~ /\.git { | |
deny all; | |
} | |
location = /robots.txt { | |
allow all; | |
log_not_found off; | |
access_log off; | |
} | |
location / { | |
# reverse proxy for next server | |
proxy_pass http://localhost:4000; | |
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; | |
# we need to remove this 404 handling | |
# because next's _next folder and own handling | |
# try_files $uri $uri/ =404; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment