#Mess with Nginx on ubunt for deployment of Nest.js and React.js
2 messages · Page 1 of 1 (latest)
Here is the Nginx configuration file that I used previously. you will need to adjust the configuration according to your specific case. if you need ssl , then install certbot , thank you .
server {
listen 80;
server_name yourdomain.com; # Replace with your domain name or ip
location /api/ {
proxy_pass http://localhost:8000; # If your backend server is running on a different port, replace it here
proxy_http_version 1.1;
# WebSocket-specific settings
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Standard proxy headers
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Disable buffering for WebSocket
proxy_buffering off;
# Handling for WebSocket and HTTP
proxy_cache_bypass $http_upgrade;
}
location / {
proxy_pass http://localhost:3000; # If your frontend server is running on a different port, replace it here
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /socket.io/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://localhost:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}