Nginx, how to allow IP:PORT requests
What's the proper way to configure Nginx to allow IP:PORT requests like this:
//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
My 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;
You have to add new serverblock for each port on your configuration. You can also set different root directory for each port. For example:
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;
..
..
}