Firstly, install nginx on the server.

1
2
3
yum update
yum install epel-release
yum install nginx

Edit the nginx config file then.

1
2
cd /etc/nginx/nginx.conf
vim nginx.conf

Edit the file like this:

1
server_name domain.com;

If you are not going to use a domain name, a public ip address would also work instead of domain.com πŸ™‚ Find the location section in the file and replace it with:

1
2
3
4
5
6
7
8
location / {
  proxy_pass http://server_ip:8080;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection 'upgrade';
  proxy_set_header Host $host;
  proxy_cache_bypass $http_upgrade;
}

And that’s it!

You can also add another app in the same nginx server block, for example, location /app_name { … … }, which means that the server relays from the route /app_name, and another port, of course.

Last but not least, don’t forget to check the server’s selinux settings.

1
2
getsebool -a
setsebool -P configuration_name on

Happy networking! πŸ™‚