How to serve static react app with nginx and ssl certificate

Viewed 430

I just set up nginx with ssl certificate, copied my build directory to /var/www/mydomain and the little lock on the browser reflects, but the problem is when I hit the mydoma.com the index.html in /var/www/mydomain directory is loaded but the other pages are not, thus showing a blank page - only works with safari browser.

The nginx was serving the react app normally before I added the ssl cert and accepted automatic redirect.

Here is the content of my sites-available config.

   server {
    server_name mydomain.com www.mydomain.com;
    location / {
            root /var/www/mydomain;
            index index.html index.htm;
            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;
            try_files $uri $uri/ /index.html;
    }

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/nextoma.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/nextoma.com/privkey.pem; # managed by 
Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
0 Answers
Related