nginx – proxy_pass /subfolder – destination files 404'ing. Rewrite rule required?

I have two servers running nginx:

Server 1 has a range of projects on it Server 2 has a new Vue/Nuxtjs (node)

On server 1 I have set up a proxy_pass to the static IP of server 2 where my node based app is running. So the goal is for users to just see http://domain.tld/folder, http://domain.tld/folder/login etc when they browse the site

Server 1:

location /folder/ { 
  proxy_pass; // IP of server 2

Server 2:

location / {
  proxy_pass http://localhost:3000;

This works partly but all assets are 404. And when clicking links the browser visits http://domain.tld/login

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi Alex - thanks for this. It did not seem to have any effect (I made sure to restart nginx)

Do I need to do anything on server 2?

Hello, @ltyler

You’ll need to use/add some extra rules in order to setup this. You can use proxy_set_header to set this. You can try with the following snippet of code on server 1:

    location /folder {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Let me know how it goes.

Regards, Alex