Created
July 29, 2021 08:48
-
-
Save justerror/af1bf72a9662d3945f6eb8a9c845c62f to your computer and use it in GitHub Desktop.
NGINX configuration for Dockerized Angular Universal app
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
map $cache $expires { | |
1 max; | |
0 -1; | |
default off; | |
} | |
map $uri $cache { | |
"~*\.[0-9a-f]{8,32}\..*$" 1; | |
~* 0; | |
} | |
server { | |
listen 443 ssl http2; | |
server_name example.com www.example.com; | |
expires $expires; | |
location / { | |
proxy_pass http://127.0.0.1:4000; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_http_version 1.1; | |
proxy_set_header X-NginX-Proxy true; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_cache_bypass $http_upgrade; | |
proxy_redirect off; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
} | |
location = /robots.txt { | |
add_header Content-Type text/plain; | |
return 200 "User-agent: *\nDisallow:\n"; | |
} | |
location ~ /\. { | |
deny all; | |
} | |
} | |
server { | |
listen 80; | |
server_name example.com www.example.com; | |
return 301 https://$host$request_uri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment