A quick reference to Nginx
Created on: 2019-12-03
Tag: cheat_sheet
Warning
under heavy construction and not well organized
by default nginx access log can be found at:
/var/log/nginx/access.log
and the error log at:
/var/log/nginx/error.log
https://stackoverflow.com/a/38238001/5350059
https://serverfault.com/questions/514044/nginx-is-cutting-the-end-of-dynamic-pages-and-caching-them
https://www.digitalocean.com/community/questions/404-error-page-instead-of-default-nginx-welcome-page https://serverfault.com/questions/354803/nginx-custom-404-error-page-for-virtual-host
reverse proxy config:
http { server { listen 80; server_name foo.com; location /service1/ { proxy_pass http://$IP:PORT/; } location /service2/ { proxy_pass http://$IP:PORT/; } } }
simple reverse proxy with ssl:
server { listen 80; return 301 https://$host$request_uri; } server { listen 443; server_name sub.domain.com; ssl_certificate /etc/nginx/cert.crt; ssl_certificate_key /etc/nginx/cert.key; ssl on; location / { proxy_pass http://localhost:8080; } }
to replace or remove subdirectory in reverse proxy:
location /site1/ { proxy_pass http://localhost:8081/; # ... more config ... # }
notice the tailing / both after the site and http://localhost:8081