'502 Bad Gateway nginx when testing
I need help on this issue I have while trying to redirect and forward traffic to an external server and below are my nginx configurations. I am new in nginx and I have read some documentations and I could not fix this. Can anybody please help me.
when I try to curl the URL using http it does respond but when I curl using https I also get the 502 error
nginx.config:
location /insights/ {
proxy_set_header Host ‘myweb.othersite.com';
proxy_hide_header Set-Cookie;
proxy_ignore_headers Set-Cookie;
proxy_set_header Cookie "";
proxy_intercept_errors on;
proxy_cache s3_cache_zone;
proxy_cache_key $country_code$uri;
proxy_cache_bypass $arg_nocache;
proxy_cache_valid 200 1h;
add_header X-myweb-Cache $upstream_cache_status;
rewrite ^/insights/.+$ https://$host/insights/ permanent;
proxy_pass https://myweb.othersite.com$country_code;
}
http {
map $http_host $country_code {
mysite.hk 'hk';
mysite.co.id 'id';
default '';
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
