Nginx 反向代理到服务 php 的 apache 服务器

时间:2021-02-05 14:55:57

标签: php docker apache nginx

我在主机和 apache2 服务器上安装了一个 nginx,并在具有隔离桥接网络的 docker 中运行。下面是我的 nginx 配置文件,访问 http://example.com 时一切正常。

add_action('woocommerce_billing_fields', 'autocomplete_nope');
function autocomplete_nope( $fields ) {
    $fields['billing']['billing_phone']['autocomplete'] = false;
    return $fields;
}

但是当我使用 certbot --nginx 安装证书时,会创建新的 nginx 配置文件:

server {
    index index.php index.htm index.html;
    server_name example.com;

    location / {
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
       proxy_pass http://127.0.0.1:7777;
       proxy_set_header Host $host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $remote_addr;
    }
}

当我用这个新的配置文件访问 https://example.com 时,php 文件没有被执行,就像 css 和 js 没有被执行一样,php 文件的内容只是被展示了。解决该问题的唯一方法是在我的配置文件中添加 add_header Content-Security-Policy upgrade-insecure-requests; 行,但这会导致速度缓慢,并且某些浏览器显然不支持此配置。有没有办法在不损害网站性能的情况下解决这个问题?

0 个答案:

没有答案