配置Nginx以允许DOMAIN的正确方法是什么:像这样的PORT请求:
http://example.com:8080/?a=xxx&b=yyy&c=zzz
over TCP or UDP
和IP:像这样的PORT请求:
http://1.2.3.4:8086/?a=xxx&b=yyy&c=zzz
over TCP or UDP
Nginx还必须允许这样的域请求,这些请求已在我的设置上正常运行:
http://example.com/home
http://example.com/work
over TCP
对于IP:PORT请求,我尝试了这个配置,但它没有工作:
server {
listen 8080;
server_name 1.2.3.4:8080;
root /home/public_html/example.com;
location / {
client_max_body_size 10m;
client_body_buffer_size 20m;
proxy_connect_timeout 10s;
proxy_send_timeout 5s;
proxy_read_timeout 60s;
proxy_buffer_size 8k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_redirect off;
proxy_pass http://1.2.3.4:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
# HTTP IP:PORT ...
# http://example.com:8080/app/?ip=1.2.3.4&pt=55555&do=things
# there's a listener on port 55555
#
listen 8080;
server_name example.com www.example.com;
root /home/public_html/example.com;
location /app {
client_max_body_size 128k;
client_body_buffer_size 256k;
proxy_connect_timeout 10s;
proxy_send_timeout 5s;
proxy_read_timeout 60s;
proxy_buffer_size 8k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_ignore_client_abort on;
proxy_pass http://$arg_ip:$arg_pt;
proxy_redirect off;
}
}
答案 0 :(得分:1)
您应该能够像这样配置:
#resolve domain with no port or port 80
server {
listen 80;
server_name example.com www.example.com;
...
#resolve domain for port 8080
server {
listen 8080;
server_name example.com www.example.com;
...
#resolve with IP on port 8086
server {
listen 8086 default_server;
server_name example.com www.example.com;
...
服务器名称不应包含端口(这是listen指令的重点),default_server是解析IP地址的端口。
您可以找到有关NGINX配置here的详细信息。