Score:0

Is it possible to proxy two http service with different port using nginx reverse proxy?

cn flag

I have two http services running in ubuntu server and they're using port 4000, 8080.

If I directly visit http://my.domain:4000, http://my.domain:8080, they're working fine.

But using port number is ugly url, and I am going to visit these sites using follow urls and block 4000, 8080 ports from outside.

svc1 -> http://my.domain
svc2 -> http://my.domain/svc2

Can I make this possible with Ngnix reverse proxy?

If this is impossible, can I do this?

svc1 -> http://my.domain/svc1
svc2 -> http://my.domain/svc2

JonasCz avatar
cn flag
Yes, it is possible, https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/ has some examples of using `proxy_pass` with a specific port. However the Proxied application (svc1 and svc2), need to support being behind a reverse proxy which changes the URL, so that they will generate the correct links inside the HTML and other components and scripts (i.e. `http://my.domain/svc1/script.js` instead of `http://my.domain:4000/script.js`). See qBittorrent's setup guide for Nginx for example how it's often done: https://github.com/qbittorrent/qBittorrent/wiki/NGINX-Reverse-Proxy-for-Web-UI
Denis Turgenev avatar
cn flag
thank you ! ! !
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.