nginx doesn’t listen on port 80 twice?

When you specify default_server flag on a listen directive, nginx will use that server block to serve any request where HTTP Host header does not match the server_name in any other server blocks (or the request missing Host header at all). You can use default_server flag on any particular IP:port combination given as parameter of … Read more

How do I rewrite URLs in a proxy response in NGINX

We should first read the documentation on proxy_pass carefully and fully. The URI passed to upstream server is determined based on whether “proxy_pass” directive is used with URI or not. Trailing slash in proxy_pass directive means that URI is present and equal to /. Absense of trailing slash means hat URI is absent. Proxy_pass with … Read more

recommended nginx configuration for meteor

Although I’m not an nginx expert, I feel like I have a much better understanding of how to do this now. As I figure out more I’ll update this answer. One possible solution to my original question is this: location ~* “^/[a-z0-9]{40}\.(css|js)$” { root /home/ubuntu/app/bundle/programs/web.browser; access_log off; expires max; } Which says: Any URL for … Read more

Nginx location priority

From the HTTP core module docs: Directives with the “=” prefix that match the query exactly. If found, searching stops. All remaining directives with conventional strings. If this match used the “^~” prefix, searching stops. Regular expressions, in the order they are defined in the configuration file. If #3 yielded a match, that result is … Read more

Why is nginx responding to any domain name?

The first server block in the nginx config is the default for all requests that hit the server for which there is no specific server block. So in your config, assuming your real domain is REAL.COM, when a user types that in, it will resolve to your server, and since there is no server block … Read more

React-router and nginx

The location block in your nginx config should be: location / { try_files $uri /index.html; } The problem is that requests to the index.html file work, but you’re not currently telling nginx to forward other requests to the index.html file too.