A little confused about trailing slash behavior in nginx

They are totally different. In the first proxy_pass statement you have included a URI parameter with a value of /. In the second you haven’t. When you give proxy_pass a URI parameter (within a prefix location), it transforms the requested URI similarly to the alias function, whereby the value of the location directive is substituted … Read more

Nginx: Redirect non-www to www https

Make one server block a default server and give the other server block the one true server_name. server { listen 80 default_server; listen 443 ssl default_server; ssl_certificate …; ssl_certificate_key …; return 301 https://www.example.com$request_uri; } server { listen 443 ssl; server_name www.example.com; ssl_certificate …; ssl_certificate_key …; … } The default server for https requires a valid … Read more