在 ip 和端口而不是域名下托管服务器的 Nginx 配置
Nginx configuration for hosting server under ip and port instead of domain name
目前我的 nginx 站点可用设置为我在特定域名下托管。
server {
listen 80;
server_name mydomain.com;
access_log off;
error_log off;
location / {
proxy_pass http://127.0.0.1:3011;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
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;
}
}
如果我想 运行 127.0.0.0:3009 上的服务器和外部服务器,我如何更改 server_name 如果我点击 79.180.12.54:3009,它应该可以访问网站。
基本上把server_name改成79.180.12.54:3009
server_name
可以是IP
If someone makes a request using an IP address instead of a server name, the “Host” request header field will contain the IP address and the request can be handled using the IP address as the server name:
server_name example.org
www.example.org
""
192.168.1.1
;
目前我的 nginx 站点可用设置为我在特定域名下托管。
server {
listen 80;
server_name mydomain.com;
access_log off;
error_log off;
location / {
proxy_pass http://127.0.0.1:3011;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
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;
}
}
如果我想 运行 127.0.0.0:3009 上的服务器和外部服务器,我如何更改 server_name 如果我点击 79.180.12.54:3009,它应该可以访问网站。
基本上把server_name改成79.180.12.54:3009
server_name
可以是IP
If someone makes a request using an IP address instead of a server name, the “Host” request header field will contain the IP address and the request can be handled using the IP address as the server name:
server_name example.org
www.example.org
""
192.168.1.1
;