Why does my reverse Nginx node.js + express proxy redirect to 0.0.0.0?

I have a server configured to host multiple node.js + express applications on multiple domains via the Ngnix interface. Everything works fine, except when redirect calls are made using the express route:

res.redirect('/admin');

Then the client browser is redirected to http://0.0.0.0:8090

It seems like this should be a problem when the redirect headers come out of the expression, but just in case it matters, here is the nginx.conf file for the domain in question:

server {
    listen 0.0.0.0:80;
    server_name  *.example.com;

    access_log  /var/log/nginx_example_access.log;
    error_log  /var/log/nginx_example_error.log debug;

    # proxy to node
    location / {
        proxy_pass         http://0.0.0.0:8090/;
        proxy_redirect     off;

        proxy_set_header   Host             $proxy_host;
        proxy_max_temp_file_size 0;

        client_max_body_size       10m;
        client_body_buffer_size    128k;

        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;

        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
    }
}
+5
source share
1 answer

. nginx conf, node/express . res.redirect, req .

        proxy_set_header   Host             $proxy_host;

        proxy_set_header   Host             $host;

$proxy_host - 0.0.0.0:port

$host - - Host example.com


UPDATE

, Nginx $host $http_host, example.com:port, example.com.

+5

All Articles