设置 Nginx - Nginx 将上游名称放在 URL
Setting up Nginx - Nginx placing upstream name in URL
为什么nginx是nginx将上游名称放在重定向的URL?
这是我的 nginx.conf
:
worker_processes 1;
events {
worker_connections 1024;
}
http {
upstream servs {
server facebook.com;
}
server {
listen 80;
location / {
proxy_pass http://servs;
}
}
}
当我访问80端口时,我得到:
This site can’t be reached
servs.facebook.com’s server DNS address could not be found.
为什么将“servs.”放在facebook.com之前?
您没有在上游请求中设置 Host
header,因此 nginx
从 proxy_pass
指令构造一个值。当您使用 upstream
块时,此值是 upstream
块的名称,而不是您尝试访问的服务器的名称。
如果您使用 upstream
块,建议明确设置 Host
header:
proxy_set_header Host example.com;
有关更多信息,请参阅 this document。
为什么nginx是nginx将上游名称放在重定向的URL?
这是我的 nginx.conf
:
worker_processes 1;
events {
worker_connections 1024;
}
http {
upstream servs {
server facebook.com;
}
server {
listen 80;
location / {
proxy_pass http://servs;
}
}
}
当我访问80端口时,我得到:
This site can’t be reached
servs.facebook.com’s server DNS address could not be found.
为什么将“servs.”放在facebook.com之前?
您没有在上游请求中设置 Host
header,因此 nginx
从 proxy_pass
指令构造一个值。当您使用 upstream
块时,此值是 upstream
块的名称,而不是您尝试访问的服务器的名称。
如果您使用 upstream
块,建议明确设置 Host
header:
proxy_set_header Host example.com;
有关更多信息,请参阅 this document。