Score:1

How can I proxy pass applications to locations different from "/" with Apache?

cn flag

Let's say I have three applications on my server: node-red (1880), jupyter (8888) and pgadmin (5433)... I can successfully create a localhost proxy pass with them individually as the following:

<VirtualHost *:80>

    ServerName 127.0.0.1
    <Location "/">
        ProxyPass http://127.0.0.1:1880/
        ProxyPassReverse http://127.0.0.1:1880/
    </Location>

</VirtualHost>

I've realized all three of them work fine if I try to put them on the "/" location. However, if I try to put them in unique locations as the following:

<VirtualHost *:80>

    ServerName 127.0.0.1

    <Location "/nodered/">
        ProxyPass http://127.0.0.1:1880/
        ProxyPassReverse http://127.0.0.1:1880/
    </Location>

    <Location "/jupyter/">
        ProxyPass http://127.0.0.1:8888/
        ProxyPassReverse http://127.0.0.1:8888/
    </Location>

    <Location "/pgadmin/">
        ProxyPass http://127.0.0.1:5433/
        ProxyPassReverse http://127.0.0.1:5433/
    </Location>

</VirtualHost>

None of them work on their respective addresses http://127.0.0.1/nodered/, http://127.0.0.1/jupyter/ or http://127.0.0.1/pgadmin/... I don't know what concepts I'm missing to make this work. I think I have to use RewriteRule but I'm not sure how. Is there any generic solution to deal with this kind of situation? Or do I need to know the particularities of each application I'm trying to proxy pass to make it work?

jp flag
Did you check the error logs?
Nikita Kipriyanov avatar
za flag
So, what URIs get requested on backend servers? I suppose there could be some Javascript which doesn't have path replaced and which expects to be in /, not in, say, /jupyter/, so it wouldn't work. It is better not to change URI paths when reverse proxying.
diya avatar
la flag
Does this answer your question? [How to handle relative urls correctly with a reverse proxy](https://serverfault.com/questions/561892/how-to-handle-relative-urls-correctly-with-a-reverse-proxy)
raylight avatar
cn flag
@diya Well, the last solution https://serverfault.com/a/690555/602714 on that question actually solved the problem of absolute paths on a React app that I made for testing it. But in the case of Node-RED, Jupyter, and pgAdmin that solution didn't work... And I don't think these apps have configurations for that... Probably there's no generic way of solving it on Apache in the end, I'm having problems with WebSocket pages on Node-RED and different kinds of problems with Jupyter and pgAdmin. So it probably requires me to understand the particularities of those applications to make it work.
I sit in a Tesla and translated this thread with Ai:

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.