百度云加速正常 自己搭建的NGINX就出現400 本妹子求大神
問題描述
情況是這樣的:1# 域名解析商 解析到 百度云加速器,再從百度云加速解析到源站IP,103.25.199.246;之后客戶端打開完全正常,如下圖顯示中間的框架顯示正常。2# 下面是自己用Nginx來實現的反代加速,
源站是:mkt.guticn.com源站IP是:103.25.199.246
代理域名是:mkt.guticn.com代理IP是:自己代理的公網IP代理上的nginx配置是server { server_name mkt.guticn.com; listen 80; location / { proxy_buffering ’off’; proxy_ignore_headers ’X-Accel-Buffering’; proxy_hide_header ’Access-Control-Allow-Origin’; proxy_hide_header ’Cache-Control’; proxy_set_header Host mkt.guticn.com proxy_pass http://mkt.guticn.com; proxy_set_header X-Real-IP ’$remote_addr’; proxy_set_header X-Forwarded-For ’$proxy_add_x_forwarded_for’; proxy_hide_header ’content-security-policy’; proxy_set_header Accept-Encoding ’’; proxy_ignore_client_abort ’on’; proxy_set_header Accept-Language ’zh-CN’; proxy_set_header Connection ’upgrade’; if ($request_method = ’OPTIONS’) { add_header ’Access-Control-Allow-Origin’ ’*’; add_header ’Access-Control-Allow-Credentials’ ’true’; add_header ’Access-Control-Allow-Methods’ ’GET, POST, OPTIONS’; add_header ’Access-Control-Allow-Headers’ ’DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Accept’; add_header ’Access-Control-Max-Age’ 1728000; add_header ’Content-Type’ ’text/plain charset=UTF-8’; add_header ’Content-Length’ 0; return 204; } if ($request_method = ’POST’) { add_header ’Access-Control-Allow-Origin’ ’*’; add_header ’Access-Control-Allow-Credentials’ ’true’; add_header ’Access-Control-Allow-Methods’ ’GET, POST, OPTIONS’; add_header ’Access-Control-Allow-Headers’ ’DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Accept’; } if ($request_method = ’GET’) { add_header ’Access-Control-Allow-Origin’ ’*’; add_header ’Access-Control-Allow-Credentials’ ’true’; add_header ’Access-Control-Allow-Methods’ ’GET, POST, OPTIONS’; add_header ’Access-Control-Allow-Headers’ ’DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Accept’; } proxy_redirect ~http(.)guticn.com(.) http$guticn.com$2; proxy_cookie_domain guticn.com guticn.com; } }
出現的問題:打開http://mkt.guticn.com/onebook... ,出現400,如下圖顯示 ,不能顯示,很奇怪啊,怎么查都查不出,也抓過包過,也沒問題,就是出現400,煩的呢,小妹妹我都快瘋了,搞了幾個月了呢,老板總是催。
0x1# 然后百度云加速的就可以這樣實現,又不出現400,0x2# 我也拿了加速樂來試試,然后也是出現400錯誤,0x3# 我就覺得了,一定是配置不對的嗎?
不知道有沒有大神會呢?還是本妹子的配置錯誤呢。看到的朋友,可以試試看哦,測試方法:1、開一臺虛擬機,把上面的配置弄上去,2、把自己的實體機HOST改成虛擬機上,訪問就可以測試了。謝謝大家啦。
問題解答
回答1:妹子。既然是400的錯誤,而且還是必現的問題,那就一步一步定位,解決問題無法是排除法。我只能給你點建議了。
確定請求終點(就是出現問題的地方)nginx 通過 access.log 可以查看的
將配置最簡化,保證在最基礎的配置下功能能夠正常運行,避免多余的干擾
源站是:mkt.guticn.com代理域名是:mkt.guticn.com 你這2個域名都是一樣的嗎?客戶端訪問mkt.guticn.com地址,nginx又轉發到mkt.guticn.com地址,這樣配置是啥意思?
回答2:1、沒有什么日志返回哦,返回的就是POST 400那一條,有用的日志,其他的都是正常的日志的。2、那個已經測試過了,最簡單化的反向代理,一樣是沒有結果的呢。
就是像做CDN加速一樣。
相關文章:
