0

I created a proxypass on my nginx server, and enabled ssl on it, but with and without ssl I still get an error saying 502 bad gateway. What can I fix to resolve this?(p.s. when I use curl on localhost 6060, it returns the correct html, so I know that works, however when I curl the url it redirects to, it throws Cannot GET /iwl)

Nginx conf: location /iwl { proxy_pass http://localhost:6060; proxy_ssl_trusted_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem; proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2; }

Error log: 2019/01/17 12:29:57 [error] 1575#1575: *7 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: mysite.com, request: "GET /iwl HTTP/1.1", upstream: "http://127.0.0.1:6060/iwl", host: "mysite.com"

  • please post the entire nginx config – v25 Jan 17 at 13:51
  • The issue slightly changed, sorry. do you still need the full conf? – Jake t Jan 17 at 14:00
  • The question should reflect the current issue. Do you still need an answer? If not, you can post a solution to your own problem as an answer. Regarding the nginx config it's always good to see the surrounding code as the fault could lie outwith the code you posted. Anyone trying to solve needs to see the full context. At a guess I would say try a trailing slash on the proxy_pass line so: http://localhost:6060/; – v25 Jan 17 at 14:12
  • it worked... wow. a trailing slash was all I needed – Jake t Jan 17 at 14:36
0

Use a trailing slash on the proxy_pass line of your nginx config:

location /iwl {
   proxy_pass http://localhost:6060/;
   proxy_ssl_trusted_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem;
   proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
}
  • Sorry to nag you like this, but I changed my conf, and it does work, however, none of the scripts load in location /iwl { root /home/ubuntu/noderoot/; proxy_pass http://localhost:6060/; proxy_ssl_trusted_certificate /etc/letsencrypt/live/jakesandbox.com/fullchain.pem; proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2; } see the script error for yourself: jakesandbox.com/iwl I figured this would be a comon second error, so I decided to tack this on. Just check the console to see the script loading errors – Jake t Jan 17 at 14:56
  • @Jaket It would probably be worth creating a separate question for the script error, and include the entire nginx conf, as well as references to what 'script' is failing: is it PHP or something else, along with errors. – v25 Jan 17 at 15:02
  • alright, new thread coming up. – Jake t Jan 17 at 15:09

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.