Nginx blocking

Hello! I used to run my website without Nginx. So, it is just Nodejs who taking care of the connection and web server task. Then I learn that Nginx would be a better webserver than Nodejs and I can install Certbot to it. I follow these two tutorials: (to install Nginx) and (to install Certbot) I got my site up and running. Then I noticed that my communication is being blocked or I am getting error in the console Failed to load resource: the server responded with a status of 404 (Not Found). I did some research and I found out that I need to complete some steps to get WebSocket to work with Nginx. I tried a few codes I found online but nothing makes sense to me and it still not working.

This what looks like after I install Certbot successfully.

        root /var/www/;
        index index.html;

        location / {
                 try_files $uri $uri/ =404;

   listen [::]:443 ssl ipv6only=on; #managed by Certbot
   listen 443 ssl;
   ssl_certificate ~too lazy to type~
   ssl_certificate_key ~too lazy to type~
   include ~too lazy to type~
   ssl_dhparam ~too lazy to type~

server {
  if($host ={
      return 301 https://$host$request_uri;
  } #manage by certbot

  if($host ={
      return 301 https://$host$request_uri;
  } #manage by certbot

  listen 80;
  listen [::]:80;
  return 404; #manage by Certbot

my server.js look like this:

var express = require('express');
var app2 = express();
var server2 = app2.listen(3700);
var socket = require('');
var io = socket(server2);
io.sockets.on('connection', onNewConnections);

function onNewConnections(socket){

	 socket.on('sendToAll', sendToAllExceptToSender);

	function sendToAllExceptToSender(data){


I need help with configuration so I can get my to work. thanks!

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.

Bobby Iliev
Site Moderator
Site Moderator badge
March 7, 2020
Accepted Answer

Hi there @SephiaSky,

What you need to do is to configure your Nginx as a reverse proxy so that it could proxy your HTTP traffic to your backend application.

You can take a look at this tutorial here on how to setup Nginx as a reverse proxy:

Regards, Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel