问题原文
原帖链接 · Buno · CC BY-SA 4.0
I am changing the domain name of my app from old.com to new.com
My app is connected to external APIs that send data through webhooks, and I would like to redirect the webhooks sent to the old url, so that they hit the new url and get processed.
I have a tried a plain rewrite
server {
server_name old.com;
listen 443 ssl;
rewrite ^ https://new.com$request_uri;
I can see this triggers a 302 redirection, but that doesn't seem to do the trick..
I tried with a proxy_pass
server {
server_name old.com;
listen 443 ssl;
location /webHook {
proxy_pass https://new.com/webHook;
}
rewrite ^ https://new.com$request_uri;
Same result.. I can see a 302 redirect in the logs, but the webhook never seem to hit the new URL and doesn't get processed..
Any idea on how to achieve that?
已采纳解答
原帖链接 · Piotr P. Karwasz · CC BY-SA 4.0
The rewrite directives in the server block, which are not inside a location block are executed first (cf. ng_http_rewrite_module documentation).
So delete or comment the rewrite directive and the proxy_pass directive will get executed.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
