Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Resolution of invalidation of nginx rewrite 301Jump post request

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Upstream gaogd {server 118.8.8.8 weight=2; 80 weight=2;} server {listen 80; server_name www.gaogd.com; client_max_body_size 20m; proxy_connect_timeout 600; proxy_read_timeout 500; proxy_send_timeout 500; proxy_buffer_size 50m; proxy_buffers 32 50m; proxy_busy_buffers_size 50m Proxy_temp_file_write_size 50m; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; location / {proxy_cache off; proxy_pass http://gaogd; }} server {server_name gaogd.com; location / {if ($request_method ~ ^ (POST) $) {proxy_pass http://www.gaogd.com; break;} rewrite ^ / (. *) $http://www.gaogd.com/$1 permanent }} # 301Redirect problem solved above is to transfer the domain name gaogd.com to www.gaogd.com, but if you perform the post operation gaogd.com, if you directly use the rewrite rule to perform 301jump. Then the post request becomes a get request. Solution: before you jump, you want to determine whether the request is a get or a post request. If it is a post request, use the proxy_pass method, and vice versa, use the write method.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report