I'm not sure if my terminology is correct, so let me explain ...
If I have a domain, test.example.com
, I want to be able to map /abc
to an application on that server running on port 8080
and map another application /def
to an application running on port 8081
.
I've tried it with RabbitMQ which I'm running inside docker and exposing port 15672
, NGINX however is not inside Docker and running directly on the machine.
docker run -d --hostname rabbitmq --name rabbitmq -p 15672:15672 rabbitmq:3-management
Whether it's running inside Docker or directly on the machine, I believe is irrelevant, I have an application running on port 15672
that I want to map to location /rabbitmq
My NGINX config I've tried so far:
server {
listen 80;
server_name test.example.com;
location /rabbitmq {
proxy_pass http://127.0.0.1:15672;
}
}
When going to test.example.com/rabbitmq
I'm seeing the following:
I don't know if that's NGINX's page or RabbitMQ's page showing not found.
Opening port 15672
on the server I can clearly get to RabbitMQ
And going to :15672/blah
it seems to be the same not-found page, so it must be getting to RabbitMQ.
RabbitMQ is listening on 0.0.0.0:15672
, so it should work from any domain, host or ip.
So how do I make test.example.com/rabbitmq
actually serve the content of test.example.com:15672
?
I got it working using a rewrite:
This is my nginx config; i'm using it aswell as a reverse proxy, but for my node app. "location /SienaBikes" is the nodejs app and it works properly for me.
One thing that I did (But I don't know if it applies for rabbitmq as well) is to install PM2 Daemon and run my node app as a process. Perhaps you need to do it as well or something along the lines.
Your NGINX config is fine just need to rewrite location mapping like below.