【问题标题】:Nextcloud on apache and nginx as reverse proxy + SSLNextcloud 在 apache 和 nginx 上作为反向代理 + SSL
【发布时间】:2019-02-01 23:19:00
【问题描述】:

我对 Apache 和 Nginx 感到头疼。当我认为一个人在工作时,另一个人不工作,反之亦然......

稍微解释一下:

我有一台“安装”了 Nextcloud 的服务器,它正在使用 Apache2 和 MySQL。

我有一个带有 Nginx 的 Raspberry PI,它充当反向代理。

我之前有这个设置工作,当时它不是一个干净的设置,所以我撕掉了所有东西并重新开始,希望有一个干净的配置。

路由器 80/443 => Nginx RP => Nextcloud

我尝试了许多配置文件和文档,但现在我陷入了困境:

502 错误网关 nginx/1.10.3

无论我对 Apache 或 Nginx 进行什么更改,我仍然会收到相同的消息...

这是我的 Nginx 反向配置文件:

server {

    listen rproxy_IP:80;
    server_name cloud.domain.com;
    return 301 https://$server_name$request_uri;
}

server {

    listen rproxy_IP:443 ssl;
    server_name cloud.domain.com;

    #Log storage
    access_log /var/log/nginx/cloud.domain.access.log;
    error_log /var/log/nginx/cloud.domain.error.log;

    #SSL Configurations
    ssl on;
    ssl_certificate /etc/nginx/ssl/crt.crt;
    ssl_certificate_key /etc/nginx/ssl/key.key;
    ssl_stapling on;
    ssl_stapling_verify on;

    location / {

        add_header Front-End-Https       on;
        proxy_headers_hash_max_size      512;
        proxy_headers_hash_bucket_size   64;
        proxy_set_header                 Host $host;
        proxy_set_header                 X-Forwarded-Proto $scheme;
        proxy_set_header                 X-Real-IP $remote_addr;
        proxy_set_header                 X-Forwarded-For $proxy_add_x_forwarded_for;

        # whatever the IP of your cloud server is
        proxy_pass                       https://nextcloud_IP;
    }
}

当我查看日志时,我得到了这个:

2018/08/27 13:42:25 [error] 19756#19756: *1 SSL_do_handshake() failed (SSL: error:1408F10B:SSL routines:ssl3_get_record:wrong version number) while SSL handshaking to upstream, client: **Public_IP**, server: **cloud.domain.com**, request: "GET / HTTP/1.1", upstream: "https://**nextcloud_IP**:443/", host: "**cloud.domain.com**"

我很难理解这一点,因为在今天早上之前我有相同的确切配置而且我没有问题。

现在这是我的 Nextcloud 的 Apache 配置:

    <VirtualHost rproxy_IP:80>
 DocumentRoot "/var/www/nextcloud"
 ServerName cloud.domain.com

Redirect permanent / https://cloud.domain.com/
Alias cloud.domain.com /var/www/nextcloud
 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory /var/www/nextcloud/>
 Options +FollowSymlinks
 AllowOverride All

 <IfModule mod_dav.c>
 Dav off
 </IfModule>

 SetEnv HOME /var/www/nextcloud
 SetEnv HTTP_HOME /var/www/nextcloud
 Satisfy Any

</Directory>

</VirtualHost>

这里是 Apache 日志:

[Mon Aug 27 13:21:19.874269 2018] [mpm_prefork:notice] [pid 36967] AH00169: caught SIGTERM, shutting down
[Mon Aug 27 13:21:20.899777 2018] [mpm_prefork:notice] [pid 37263] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations
[Mon Aug 27 13:21:20.899811 2018] [core:notice] [pid 37263] AH00094: Command line: '/usr/sbin/apache2'

我不得不提到我使用了通配符。

路由器有 80/443 转发到反向代理 反向代理获取 http 并将其“升级”为 https,然后将请求转发到 Apache-Nextcloud。 证书效果很好。

请帮助我,我不明白我做错了什么或什么不起作用以及为什么不起作用。如果您需要更多信息,请告诉我。我不能透露你所理解的域名、内部IP和公共IP。

提前感谢您的回答。

【问题讨论】:

    标签: apache ssl nginx config nextcloud


    【解决方案1】:

    如果我清楚地理解了您的架构,那么您有:

    Client -> Router (NAT) -> Nginx (http/https) -> Apache (http)
    

    你有 502 错误,因为你试图将请求 proxy_pass 到不存在的 443 Apache 端口。

    我认为你应该像这样修复你的 proxy_pass 字符串:

    proxy_pass http://nextcloud_IP;
    

    【讨论】:

      【解决方案2】:

      该死!它起作用了,我不再收到网关错误。谢谢 mindfl 我想当你看配置文件这么久时,你看不到这样的小问题:/

      【讨论】:

        猜你喜欢
        • 2021-07-06
        • 2017-08-16
        • 2019-06-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-06-06
        • 2021-03-26
        • 2015-10-06
        相关资源
        最近更新 更多