Hello,
I have been struggling 2 whole days already with this problem. I’ve set up a reactjs app, nodejs backend server and mysql database on the same droplet. I can visit the react site (www.xxx.com) without problems, my backend is also running. But I cannot connect frontend to backend, I always get “ERR_SSL_PROTOCOL_ERROR” (on my local windows machine, everything is working perfectly). It seems the backend server doesnt make a secure connection. When I do ip_address:8800?api-command, I get a response. So, it is working. I connect from FE to BE like this: “https://ip_address_droplet:8800”
I have to admit, I never used Nginx before, but this is my config file:
server {
root /var/www/sitename.com/html/build;
index index.html index.htm index.nginx-debian.html;
server_name sitename.com;
location / {
try_files $uri $uri/ =404;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/sitename.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/sitename.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
}
server {
server_name nodejs.sitename.com;
location / {
proxy_pass http://localhost:8800; #whatever port your app runs on
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;
}
}
server {
if ($host = sitename.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
server_name sitename.com;
return 404; # managed by Certbot
}
Can someone guide me into the right direction? What am I doing wrong?
Thx, Peter
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!
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.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Thanks for your help! It put me in the right direction. And at the end, after following what you said, I found what was causing the biggest issue: the way I connected to the backend “https://ip_address_droplet:8800” When I remove :8800, all runs smoothly
thx
Hi there,
The server block configuration for your
nodejs.sitename.com
site is not correct. You need to have the listener port in there as well and it is best to install an SSL certificate for this site too otherwise you will get a mixed content error.What I would suggest is:
nodejs
subdomain for port 80, eg:certbot
:The
certbot
command will automatically configure the server block for port 443 for you.This should fix the issue that you are seeing.
Let me know how it goes!
Best,
Bobby