I have a setup where i can access to my docker containers through nginx proxy. All containers are in internal network and does not have access to the internet. Now I need to send webhook to slack from my docker container. In container i edited file "/etc/hosts", just added a record to my proxy, which is similiar to hooks.slack.com. I did this, because container sending request to proxy, after that proxy get it and redirects to the internet original hooks.slack.com.
server {
listen 80;
server_name hooks.slack.com;
return 301 https://hooks.slack.com$reques_uri;
}
When i am testing this by CURL from my docker container i get answer 301 and nothing happened, no message delivered to slack.
SOLVED:
Needed to add this intead of my actual setup.
server {
listen 80;
server_name hooks.slack.com
location / {
proxy_pass https://hooks.slack.com;
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
}
}
CodePudding user response:
Use proxy_pass
instead of 301 redirect
server {
listen 80;
server_name hooks.slack.com;
location / {
proxy_pass https://hooks.slack.com;
}
}