gpt4 book ai didi

Nginx,如何允许DOMAIN :PORT and IP:PORT requests

转载 作者:行者123 更新时间:2023-12-05 03:13:12 26 4
gpt4 key购买 nike

配置 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;
}
}

最佳答案

你应该可以这样配置:

#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 .

关于Nginx,如何允许DOMAIN :PORT and IP:PORT requests,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30880101/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com