配置 Nginx 以允许 IP:PORT 请求的正确方法是什么,如下所示:
//App is deployed on 8086
http://X.X.X.X:8086/?a=xxx&b=yyy&c=zzz ((http requests))
over TCP or UDP
//Another app is deployed on 5050
http://X.X.X.X:5050/postRequest (http requests)
over TCP or UDP
我的 nginx.conf
server {
include /etc/nginx/conf.d/*.conf;
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /home/ubuntu/var/www/html;
index index.html index.htm default.html;
access_log /etc/nginx/logs/access.log mycustomformat;
答案1
您必须在配置中为每个端口添加新的服务器块。您还可以为每个端口设置不同的根目录。例如:
server {
include /etc/nginx/conf.d/*.conf;
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /home/ubuntu/var/www/html;
index index.html index.htm default.html;
access_log /etc/nginx/logs/access.log mycustomformat;
..
..
}
server {
include /etc/nginx/conf.d/*.conf;
listen 8086;
listen [::]:8086;
server_name _;
root /home/ubuntu/var/www/your8086dir;
index index.html index.htm default.html;
access_log /etc/nginx/logs/access-8086.log mycustomformat;
..
..
}
server {
include /etc/nginx/conf.d/*.conf;
listen 5050;
listen [::]:5050;
server_name _;
root /home/ubuntu/var/www/your5050dir;
index index.html index.htm default.html;
access_log /etc/nginx/logs/access-5050.log mycustomformat;
..
..
}