微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

nginx 代理后面带有 apache2 的 Nextcloud:502 错误网关错误

如何解决nginx 代理后面带有 apache2 的 Nextcloud:502 错误网关错误

在您查看我的配置之前,我想为这次混乱提前道歉。这是第一次使用 apache 和 Nginx,我基本上只是将堆栈溢出中的每个提示复制到我的配置中,希望有一些有用的东西。

重启我的树莓派后,当我尝试访问 xxx.duckdns.org 下的 nextcloud 服务器时,我收到 Nginx 502 错误网关错误

Nginx 配置:

map $http_upgrade $connection_upgrade {
  default upgrade;
  ''      close;
}

server {
  listen 80;
  server_name xxx.duckdns.org;
  return 301 https://$host$request_uri;
}

# SSL configuration
server {
  listen 443 ssl;
  server_name xxx.duckdns.org;
    ssl_certificate /etc/letsencrypt/live/xxx.duckdns.org/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/xxx.duckdns.org/privkey.pem; # managed by Certbot

  # Improve HTTPS performance with session resumption
  ssl_session_cache shared:SSL:10m;
  ssl_session_timeout 5m;

  # Enable server-side protection against BEAST attacks
  ssl_prefer_server_ciphers on;
  ssl_ciphers xxx;

  # disable SSLv3
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

  # Diffie-Hellman parameter for DHE ciphersuites
  ssl_dhparam /etc/ssl/certs/dhparam.pem;

  # Enable HSTS (https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security)
  add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";

  # Enable OCSP stapling (http://blog.mozilla.org/security/2013/07/29/ocsp-stapling-in-firefox)
  ssl_stapling on;
  ssl_stapling_verify on;
  ssl_trusted_certificate /etc/letsencrypt/live/xxx.duckdns.org/fullchain.pem;
  resolver 8.8.8.8 8.8.4.4 valid=300s;
  resolver_timeout 5s;

  location / {
    set $fixed_destination $http_destination;
    if ( $http_destination ~* ^https(.*)$ ) {
       set $fixed_destination http$1;
       }
    proxy_set_header Destination $fixed_destination;
    proxy_set_header Host $http_host;

    proxy_pass https://192.168.0.254:8080;
    proxy_set_header Host $host;
    proxy_redirect http:// https://;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
  }

}
  

Apache2 配置:

<IfModule mod_ssl.c>
  <VirtualHost 192.168.0.254:8080>
    DocumentRoot /var/www/nextcloud
    ServerName xxx.duckdns.org
    CustomLog /var/log/apache2/nc-access.log combined
    ErrorLog  /var/log/apache2/nc-error.log
  </VirtualHost>
  <Directory /var/www/nextcloud/>
    Options +FollowSymlinks
    AllowOverride All
    <IfModule mod_dav.c>
      Dav off
    </IfModule>
    LimitRequestBody 0
    SSLRenegBufferSize 10486000
  </Directory>
  <IfModule mod_headers.c>
    Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains"
  </IfModule>
</IfModule>

提前致谢!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。