Nginx   发布时间:2022-05-11  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了nginx – proxy_set_header无效大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

在/ etc / Nginx的/网站可用/默认

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/Nginx/html;
    index index.html index.htm;

    # Make site accessible from http://localhost/
    server_name mywebsite.net;
    return 301 https://$host$request_uri;
}
server {
    listen 443;
    server_name localhost mywebsite.net;
    ssl on;
    ssl_certificate /etc/ssl/certs/odoo.crt;
    ssl_certificate_key /etc/ssl/private/odoo.key;

    ssl_session_timeout 5m;

    ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
    ssl_prefer_server_ciphers on;

    LOCATIOn / {
      #     try_files $uri $uri/ =404;
             proxy_pass http://127.0.0.1:8069;
            include proxy_params;
    }
    LOCATIOn ~ \.(css|js|png|gif|jpeg|jpg|swf|ico|woff){
        root /usr/lib/python2.7/dist-packages/openerp/addons;
        expires 360d;
    }
@H_419_7@

}

的/ etc / Nginx的/ proxy_params

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-ForWARDed-For $proxy_add_x_forWARDed_for;
proxy_set_header X-ForWARDed-Proto $scheR_376_11845@e;
proxy_set_header x-frame-options "deny";
@H_419_7@

当我运行“curl -I -k https://mywebsite.net”时,我得到以下标题,

http/1.1 200 OK
Date: Fri,14 Oct 2016 06:43:46 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Set-Cookie: __cfduid=ddf89f52ff3c396f0a6c10af34a65d4281476427426;     expires=Sat,14-Oct-17 06:43:46 GMT; path=/; domain=mywebsite.net; httpOnly
Set-Cookie: session_id=b9bf4dc131a232eb2417eaa4a9fbe0e7f51a96f0; Expires=Thu,12-Jan-2017 06:43:45 GMT; Max-Age=7776000; Path=/
Server: cloudFlare-Nginx
CF-RAY: 2f190f162b2a2dc7-BOM
@H_419_7@

我没有得到proxy_params中包含的标头.我认为proxy_set_header无法正常工作.有什么问题?

谢谢

最佳答案
你弄错了.

proxy_set_header指令设置Nginx发送到后端的标头(在您的情况下为127.0.0.1:8069).

你需要的是add_header指令.

大佬总结

以上是大佬教程为你收集整理的nginx – proxy_set_header无效全部内容,希望文章能够帮你解决nginx – proxy_set_header无效所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: