I have a web server running on 8030 port and some static web files which should be accessed through 80 port. Both front-end and back-end files are on same linux machine.
The front-end receives data from back-end using REST API. I have a static IP and a domain name. DNS server is a CDN which connects https://a.b.com to my IP address, i.e. 1.2.3.4 here. My server itself has no SSL certifications.
So my front-end app is hosted on https://a.b.com and makes GET requests to http://1.2.3.4:8030/v1/getdata
This is my NGINX configuration file:
upstream backend {
server 1.2.3.4:8030;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
root /home/user/static;
index index.html;
server_name https://a.b.com;
location / {
try_files $uri$args $uri$args/ /index.html;
}
location /v1 {
proxy_pass http://backend;
}
}
Static files are loaded successfully but the AJAX GET request to my application server returns "502 Bad Gateway".
How can I fix this?
Firewall rules are set and remote access using static IP is OK.
question from:
https://stackoverflow.com/questions/65884750/502-bad-gatway-error-after-in-nginx-after-reverse-proxy-of-https-to-http 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…