i need to put my node js application on server, it’s actually two applications :
app1(frontend) on VM-link:3000, when the user writes the message it calls the app2 (Backend) on VM-link:3001 or VM-link:3001/socket.io/
So i used a nginx proxy to relate these two virtual machines in my www.domain.com and i wanted them to run on domain.com/chatbot
my nginx config file :
server {
listen [::]:80;
server_name domain.com;
access_log /var/log/nginx/permit_access.log;
error_log /var/log/nginx/permit_error.log;
location /chatbot {
proxy_pass http://VM-link: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;
# Websockets support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade"; }
location /back {
proxy_pass http://VM-link:3001;
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;
# Websockets support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /socket.io {
proxy_pass http://VM-Link:3001/socket.io/;
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;
}
}
Problem : when i write domain.com/chatbot and i write a message it calls domain.com:3001
Question : how can i fix this without touching the code (i mean using the config file)
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!
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.