By Lewis Tyler
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 http://200.1.1.1/; // 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
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!
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_pass http://200.1.1.1/3000;
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
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?
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.