1. 程式人生 > >關於http和https允許請求設定header問題

關於http和https允許請求設定header問題

在給微信小程式提供介面的時候使用的是https,token是放在header裡面,
不過伺服器一直沒獲取到,懷疑可能是nginx沒有允許設定header。解決辦法就是在nginx配置檔案裡面加上underscores_in_headers on;

 ### wechatapi Start
  upstream wechatapi {
    server  localhost:8009;
  }
  server {
      listen  443 ssl;
      server_name api.test.org;
      underscores_in_headers on;
      ssl on;
      ssl_certificate /ssl/bundle.crt;
      ssl_certificate_key /ssl/txzs_unsecure.key;
      client_max_body_size 20
M; access_log /system/logs/wechatapi_access.log; error_log /system/logs/wechatapi_error.log; root /system/wechatapi/current/public; index index.html; location / { try_files $uri @wechatapi; } location @wechatapi { proxy_read_timeout 300; proxy_connect_timeout 300
; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://wechatapi; } error_page 403 /500.html; error_page 404 /500.html; error_page 405
/500.html; error_page 500 501 502 503 504 /500.html; location ^~ /error/ { internal; root /system/wechatapi/current/public; } location /images/ { try_files $uri /images/error.jpg; } } # wechatapi end