By swapnilbaxi
Hi, We have hosted the Nodejs application using nginx as webserver with digicert ssl mapped to it.
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
types_hash_max_size 2048;
server_tokens off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log debug;
add_header Set-Cookie "HttpOnly; Secure";
add_header X-Frame-Options "SAMEORIGIN";
gzip off;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
server
{
listen 80;
server_name mydomain.com www.mydomain.com;
return 301 https://$host$request_uri;
}
server {
large_client_header_buffers 4 16k;
listen 443 ssl;
server_name mydomain.com www.mydomain.com;
access_log /var/log/nginx/nginx.vhost.access.log;
error_log /var/log/nginx/nginx.vhost.error.log;
ssl_certificate /etc/ssl/certs/bundle.crt;
ssl_certificate_key /etc/ssl/certs/www_mydomain_com.key;
ssl_prefer_server_ciphers on;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass https://www.mydomain.com:8080;
}
location ~ ^/(room|socket\.io) {
proxy_pass https://www.mydomain.com:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
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;
proxy_pass_request_headers on;
}
location /wsapp {
proxy_pass https://www.mydomain.com:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_hide_header 'Access-Control-Allow-Origin';
}
}
const server = require('https').createServer(credentials, app).listen(8080, 'www.mydoamin.com');
const io = require('socket.io')(server,
{
cors: {
origin: ["https://www.mydomain.com:*"],
methods: ["GET", "POST"],
transports: ['websocket', 'polling'],
autoConnect: true,
pingInterval: 25000,
pingTimeout: 180000,
},
allowEIO3: true,
cookie: {
name: "domainio",
httpOnly: false,
secure: true
}
});
var socket = io.connect('https://www.mydomain.com',
{
'transports': ['polling'],
'autoConnect': true,
'pingInterval': 25000, // default - 25000
'pingTimeout': 180000, // default - 60000
'reconnection': true,
'reconnectionDelay': 1000,
'reconnectionDelayMax': 5000,
'reconnectionAttempts': 5,
'secure': true
});
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!
Hi @swapnilbaxi,
I’ll urge to you check your Nginx Error Logs, the error will most certainly be logged there. Once it’s logged there it will be a more specific one rather than just Generic 400 Error.
Once you have the specific error you can further troubleshoot what’s going on. Until tell it’s just some shots in the dark.
If you are unable to find a solution once you have the errors from the Nginx Error_log, you can post them here, we’ll try to help out!
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.