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/;
        }
}

相关内容