Ubuntu 18 on AWS using Nginx and Cloudflare


I’ve built an application using Node, Express, Passport and so on, and the last task was to get it working with Cloudflare for secure services.

I followed the instructions in an article, and having saved the appropriate files for the certification the application has the padlock symbol next to the web address.

However, when I access the application, I get a series of errors:

GET https://www.theundercloud.com:2096/socket.io/?EIO=3&transport=polling&t=N4NTqwJ net::ERR_FAILED

Access to XMLHttpRequest at ‘https://www.theundercloud.com:2096/socket.io/?EIO=3&transport=polling&t=N4NTtPU’ from origin ‘https://www.theundercloud.com’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

In the “.env” file, I have:



In the “/etc/nginx/sites-enabled/udrcld.conf” I have:

server {
    listen 80;
    listen [::]:80;
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    ssl on;
    ssl_certificate /etc/ssl/certs/certificate-cloudflare.pem;
    ssl_certificate_key /etc/ssl/key-cloudflare.pem;
    server_name www.theundercloud.com www.udrcld.com;
    charset utf-8;
    root /var/www/html/udrcld/dist;
    index index.html index.htm;
    # Always serve index.html for any request
    location / {
        root /var/www/html/udrcld/dist;
        try_files $uri /index.html;
    error_log /var/log/nginx/vue-app-error.log;
    access_log /var/log/nginx/vue-app-access.log;

In the “udrcld/config/prod.env.js” I have:

module.exports = {
  NODE_ENV: '"production"',
  APP_URL: '"https://www.theundercloud.com:4200"',
  ROOT_API: '"https://www.theundercloud.com:3000"',
  SOCKET_PORT: '2096',
  SOCKET_URL: '"https://www.theundercloud.com:2096"'

And in the Security Group on AWS I have the appropriate entries for port 2096.

I am using port 8899 in development, and that same port was working prior to using Cloudflare, but I had problems with it, and I’ve since learned it’s not supported, so I switched to 2096.

In the Registered Domains section of Route 53 on AWS, I’ve changed the name servers to those of Cloudflare.

I’ve followed a few different tutorials, such as:

… but neither helped.

Ideas welcome!

This topic was automatically closed after 31 days. New replies are no longer allowed.