Apache ReverseProxy 到 Nginx 仅显示 Nginx 的默认 localhost 域

Apache ReverseProxy 到 Nginx 仅显示 Nginx 的默认 localhost 域

我正在从 CentOS Nginx 在 Apache ReverseProxy 上配置 Tuleap。

Tuleap 在 CentOS 上成功运行并可访问。

配置我已经用于glassfish的反向代理后,另一个具有相同配置的apache服务器运行正常。但nginx只显示localhost页面。

查看nginx tuleap host和apache reverseproxy host的配置文件

nginx配置:

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections  1024;
}


http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;
}

nginx 上的 tuleap 主机:

upstream tuleap {
    server 127.0.0.1:8080;
}

server {
        listen       443 ssl;
        server_name  tuleap.cent.example.com;

        ssl_certificate /etc/pki/tls/certs/localhost.crt;
        ssl_certificate_key /etc/pki/tls/private/localhost.key;
        ssl_session_timeout 1d;
        ssl_session_cache shared:SSL:50m;
        ssl_session_tickets off;

        # intermediate configuration. tweak to your needs.
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers '';
        ssl_prefer_server_ciphers on;

        # Tweak for file upload and SVN
        client_max_body_size 64M;

        include conf.d/tuleap.d/*.conf;

        # Available here in case of emergency, uncomment the
        # line below (and comment the line above)
        #include conf.d/tuleap-apache.proxy;
}

server {
    listen       80;
    server_name  tuleap.cent.example.com;
    # Tweak for file upload and SVN
    client_max_body_size 64M;
    include conf.d/tuleap.d/*.conf;
}

Apache 反向代理配置:

<VirtualHost *:443>
    ServerName bugs.example.org
    SSLEngine On
    SSLCertificateFile "/etc/letsencrypt/live/bugs.example.org/fullchain.pem"
    SSLCertificateKeyFile "/etc/letsencrypt/live/bugs.example.org/privkey.pem"
    ProxyRequests Off
    ProxyPreserveHost On
    AllowEncodedSlashes NoDecode

    ProxyPass / http://tuleap.cent.example.com/ nocanon
    ProxyPassReverse / http://tuleap.cent.example.com/
    ProxyPassReverse / http://bugs.example.org/

    <Proxy *>
        Order deny,allow
        Allow from all
        Require all granted
    </Proxy>

    <Location />
        Order allow,deny
        Allow from all
        Require all granted
    </Location>
</VirtualHost>

如果需要更新 nginx 配置文件,请告诉我。

答案1

尝试添加

proxy_set_header Host $http_host;

代理你的请求时,它使用http://127.0.0.1:8080/地址没有设置正确的主机标头,这在 apache 中由

ProxyPreserveHost On

相关内容