Nginx 反向代理頁面載入大約需要 15 秒

Nginx 反向代理頁面載入大約需要 15 秒

這是我第一次使用 nginx,所以我真的不知道這是否符合預期。如果沒有 nginx,頁面通常應在大約 5 秒內啟動。我檢查了錯誤日誌,似乎沒有任何錯誤。

這是我的 nginx 設定:

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name localhost;
        return 301 https://$server_name$request_uri;

        root /var/www/html;
        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }


server {
        # SSL Configuration
        listen 443 ssl http2 default_server;
        listen [::]:443 ssl http2 default_server;
        server_name localhost;
        include snippets/self-signed.conf;
        include snippets/ssl-params.conf;
        # HTTP Basic Auth
        auth_basic "Private Property";
        auth_basic_user_file /etc/nginx/.htpasswd;
        # Proxy Settings
        proxy_buffers 32 4m;
        proxy_busy_buffers_size 25m;
        proxy_buffer_size 512k;
        proxy_ignore_headers "Cache-Control" "Expires";
        proxy_max_temp_file_size 0;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        client_max_body_size 1024m;
        client_body_buffer_size 4m;
        proxy_connect_timeout 300;
        proxy_read_timeout 300;
        proxy_send_timeout 300;
        proxy_intercept_errors off;
        proxy_set_header Referer $http_referrer;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_redirect off;
        proxy_headers_hash_max_size 512;

        location / {
                proxy_pass http://127.0.0.1:8080/;
        }
        location /graphql {
                proxy_pass http://127.0.0.1:4200/;
        }
}

相關內容