How to deploy a React website using nginx and a domain

Viewed 25

I'm setting up a web app, with a react frontend that I want to expose and some local backend modules, all deployed in docker-compose. Everything works fine in localhost.

Now, I need to use nginx to proxy the requests to my purchased domain, using a cloudflare website, and later using https. In Cloudflare, the SSL/TLS encryption mode is Off, for testing with http. Everything has been setup in cloudflare, according to some docs that I read. Unfortunatly, my nginx configuration is only working for localhost, preventing me from doing a https configuration. (getting 522 error when loading the page using my domain).

This is my nginx config file:

server {
    listen 80;
    server_name mydomain;

    root   /usr/share/nginx/html;
    index  index.html index.htm;
    location / {
        
        try_files $uri $uri/ /index.html;
    }
    location /statsmodule {
        proxy_pass http://statsmodule:3020;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $http_host;
        proxy_cache_bypass $http_upgrade;
    }
    location /auth {
        proxy_pass http://auth:3003;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $http_host;
        proxy_cache_bypass $http_upgrade;
    }
    (...)
    # the other location blocks for the other services are similar to this
}

What am I missing?

0 Answers
Related