Reputation: 1865
I have an application that runs on port 5555. I have set up a reverse proxy from port 5554 to 5555 using NGINX and have basic authentication on it. Here is my default.conf
file
server {
listen 5554;
listen [::]:5554;
server_name 123.123.123.123;
location / {
auth_basic "protected gateway area";
auth_basic_user_file /etc/apache2/.htpasswd;
proxy_pass http://localhost:5555;
}
}
I need to have NGINX listen on port 5555, the same port the app is running on. Then after checking authentication, the proxy should forward the request to the actual app. However, when I change the listening ports on the config file from 5554 to 5555 and send a request to 5555, the request just bypasses the proxy.
Is this possible? If so, how?
Upvotes: 1
Views: 1632
Reputation: 682
Technically, you cannot bind same port to two applications on same IP. The NGNIX reverse proxy works just like a lightweight server which listen the requests and to the configured validation/actions/routing/rewrite/header manipulation/domain validation/SSL offload etc. and after that the request reached to actual server which is designed to handle the request.
However, there is a way to handle it by having two IPs for same machine (there are various ways you can obtain multiple IPs for same machine like:
Upvotes: 0