问题原文
原帖链接 · spinalwrap · CC BY-SA 4.0
I'm trying to host a friend's site on my Ubuntu 16.04 VPS.
I myself have multiple sites up at sub1.mydomain.com, sub2.mydomain.com etc. These are nodejs apps, each of them has a proxy-pass setup in an individual file like so:
server
{
server_name sub1.mydomain.com;
location /
{
proxy_pass http://localhost:APP_PORT;
include /etc/nginx/proxy_params;
}
}
the proxy_params file contains a bunch of stuff which I simply copied from some tutorial:
proxy_buffers 16 32k;
proxy_buffer_size 64k;
proxy_busy_buffers_size 128k;
proxy_cache_bypass $http_pragma $http_authorization;
proxy_connect_timeout 59s;
proxy_hide_header X-Powered-By;
proxy_http_version 1.1;
proxy_ignore_headers Cache-Control Expires;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404;
proxy_no_cache $http_pragma $http_authorization;
proxy_pass_header Set-Cookie;
proxy_read_timeout 600;
proxy_redirect off;
proxy_send_timeout 600;
proxy_temp_file_write_size 64k;
proxy_set_header Accept-Encoding '';
proxy_set_header Cookie $http_cookie;
proxy_set_header Host $host;
proxy_set_header Proxy '';
proxy_set_header Referer $http_referer;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Original-Request $request_uri;
This has worked for me.
Now I'm trying to point my friend's domain (her-domain.com) to another node app on my server for hosting her site.
server
{
server_name her-domain.com;
location /
{
proxy_pass http://localhost:HER_APP_PORT;
include /etc/nginx/proxy_params;
}
}
funnily, this does not seem to work right. If I use google DNS (8.8.8.8) on my computer, I can reach the app reverse-proxied to that domain just fine and look at the site it serves in my browser. But if I use a default DNS, nginx will serve a 404 page.
Since I can reach the server through that domain and nginx serves that 404, I assume it is an nginx config issue. I'm new to this stuff and don't know how to debug this.
已采纳解答
原帖链接 · spinalwrap · CC BY-SA 4.0
This had nothing to do with DNS.
The issue was that the nginx config did not handle IPv6 requests properly. changing the config to
server
{
server_name her-domain.com;
listen 80;
listen [::]:80;
location /
{
proxy_pass http://localhost:APP_PORT;
include /etc/nginx/proxy_params;
}
}
fixed things.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
