多个服务器上的Nginx反向代理配置

时间:2017-12-27 13:46:39

标签: nginx reverse-proxy

我目前处于这样一种情况,即我有服务器A,它需要是生产服务器B的反向代理(两者都是Nginx)。服务器B已通过域名提供,文件站点可用如下所示:

server {
   listen         [::]:80;
   server_name    my-domain.com;
   return         301 https://$host$request_uri;
}

server {
    listen [::]:443 ssl http2;
    server_name my-domain.com;
    root /var/www/..../web;
    client_max_body_size 10M;

    location / {
            try_files $uri /app.php$is_args$args;
    }

    location ~ ^/app\.php(/|$) {
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            fastcgi_param SCRIPT_FILENAME /var/www/.../web$fastcgi_script_name;
            include fastcgi_params;

            }
 location ~ /.well-known/acme-challenge/ {
    alias /var/www/challenges/;
    try_files $uri =404;
    }
   ssl_certificate /...; # managed by Certbot
    ssl_certificate_key ..; # managed by Certbot
}

我的问题是,我是否应该将此文件放在服务器B上,并在转移域时通过代理传递从服务器A指向服务器B?

0 个答案:

没有答案