在 Web 服务器代理上,应该在代理服务器还是应用服务器上进行配置?

在 Web 服务器代理上,应该在代理服务器还是应用服务器上进行配置?

因此,我在同一网络中的代理后面运行 nextcloud 服务器。因此,代理服务器处理 SSL,应用服务器处理 nextcloud 实例。我遇到了上传和下载超时和失败的问题。我认为我可能遇到了某些配置在错误服务器上的问题,因为我最近才切换到这种设置,而不是让客户端直接连接到应用服务器。两台服务器都运行 Ubuntu 14.04 和 Nginx。

这些是不同的配置。

应用服务器:

server {
    listen 80 default_server;
    root /srv/nextcloud;
    index index.php index.html index.htm

    client_max_body_size 10G;
    fastcgi_buffers 64 4K;

    rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
        rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
        rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;

    error_page 403 /core/templates/403.php;
        error_page 404 /core/templates/404.php;

    location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README) {
                deny all;
        }

        location / {
                # The following 2 rules are only needed with webfinger
                rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
                rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

                rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
                rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;

                rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;

                try_files $uri $uri/ index.php;
        }

        location ~ \.php(?:$|/) {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include /etc/nginx/global.d/php5-params.conf;
        }

        # Optional: set long EXPIRES header on static assets
        location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
                expires 30d;
                # Optional: Don't log access to assets
                access_log off;
        }
}

代理服务器:

server {
        listen 80;
        root /srv/example.com;
        server_name example.com;

        location ~ /.well-known {
                allow all;
                try_files $uri =403;
        }

        # Force HTTPS
        location / {
                return 301 https://$host$request_uri;
        }
}

upstream cloud {
    server 192.168.77.3:80;
}

server {
    server_name example.com;
    client_max_body_size 10G;
    server_tokens off;
    listen 443 ssl http2;
    root /srv/example.com;

    # Load HTTPS config
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;  
    include /etc/nginx/global.d/https-common.conf;

    # nextcloud proxy
    location / {
        proxy_redirect off;
        proxy_set_header   X-Real-IP         $remote_addr;
        proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   Host              $http_host;
        proxy_set_header   X-NginX-Proxy     true;
        proxy_set_header   Connection        "";
        proxy_http_version 1.1;
        proxy_pass http://cloud;
    }
}

最后,这是我在代理服务器上的 https 配置,它包含在单独的文件(https-common.conf)中:

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
ssl_session_timeout 1d;
#ssl_session_cache shared:SSL:50m;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security "max-age=15768000; includeSubdomains";

所以我想我的问题是你们当中是否有人有使用代理后面的 nextcloud/owncloud 设置的经验,或者有处理 SSL 问题的丰富经验,并且能看出这种配置中存在一些明显的缺陷?谢谢!欢迎提出所有想法!

相关内容