nginx set up reverse proxy from subfolder to a port

24 Views Asked by At

I'm trying to set up a Nginx reverse proxy and I'm slowly losing my mind trying to figure it out.

I have my Nginx server listening at 80, and it performs great. I have a page with a form where I want to be able to send .json POSTs from that page to a Python HTTP server that can process the requests. I have the server at port 8000.

On the website, I want to be able to reach the server by navigating to <IP>:/sub/folder/ so that I can send the .json POSTs from my <IP>:/sub/index.html page by making a simple relative request to ./folder.

When I send a curl to <IP>:8000, I reach the server and get the correct response.

I have tried to set up Nginx proxy_pass with the following configuration:

location /sub/folder/ {
    proxy_pass http://127.0.0.1:8000/;
}

This results in a 301 which sends me from <url>/sub/folder to /sub/folder/, followed by a 404 at /sub/folder/.

If I go back to the Nginx config and turn /sub/folder/ into /sub/folder, navigating to <url>/sub/folder returns a 404.

I've tried using https, I've tried changing out 127.0.0.1 for localhost, I've tried removing the final / in the proxy_pass line, I've tried proxying to https://<IP>:<port>/sub/folder even though the HTTP server is at root, among more.

0

There are 0 best solutions below