I’m running into some SSL problems with my setup on an AWS Ubuntu VPS. I have both my React frontend and Node.js backend hosted on the same machine. The React app runs through nginx while the Node backend uses pm2 for process management.
Before adding SSL, everything worked fine with my React environment variable set to REACT_APP_API_ENDPOINT: http://[server_ip]:4000
. But once I enabled SSL certificates in nginx, I’m getting two different issues depending on my configuration:
Option 1: When I change to https://[server_ip]:4000
in my React config, I get an ERR_SSL_PROTOCOL_ERROR.
Option 2: If I keep using http://[server_ip]:4000
, browsers throw Mixed Content warnings.
Has anyone dealt with this before? I’ve temporarily disabled SSL (commented out the https parts) until I figure this out.
Here’s my current nginx configuration:
server {
# SSL config commented out for now
# listen [::]:443 ssl ipv6only=on;
# listen 443 ssl;
# ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com;
root /var/www/html;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
}
Any suggestions would be really helpful!