Skip to content

Instantly share code, notes, and snippets.

@gilangvperdana
Last active February 6, 2024 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gilangvperdana/d72681fe06c4fdb7588b0b92f620610d to your computer and use it in GitHub Desktop.
Save gilangvperdana/d72681fe06c4fdb7588b0b92f620610d to your computer and use it in GitHub Desktop.
Multi Port Nginx Block

Multi Port Reverse Proxy on Nginx Configuration

This tutorial are suitable for you if you want to reverse multi endpoint with one domain different port.

Goals

  • You can access on localhost:8443 to access localhost:9200
  • You can access on localhost:8442 to access localhost:5601

Configuration

nano /etc/nginx/sites-enabled/default
server {
    listen 8443;
    server_name _;
location / {
       proxy_pass http://localhost:9200;
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
    }
}

server {
    listen 8442;
    server_name _;
location / {
       proxy_pass http://localhost:5601;
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
        }
}
service nginx reload

Reference NGINX on RHEL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment