在docker

时间:2019-07-08 07:43:49

标签: node.js docker nginx

我在docker容器中的节点服务器下运行了一个角度应用程序。我有在端口443上运行的nginx Web服务器,它将请求转发到在端口4000上运行的上述节点服务器。当我发送第一个请求时,TTFB太高,达到10秒。我想将其减少到接近0秒,但无法成功。

我为nginx服务器conf尝试了不同的配置,但似乎没有任何效果。

nginx服务器配置文件

proxy_cache_path /etc/nginx/cache levels=1:2 keys_zone=ST_NGINX_CACHE:100m max_size=1G inactive=60m;

upstream st-gateway-server {
server 127.0.0.1:8080;
}

upstream st-ui {
server 127.0.0.1:4000;
}

server {
  listen 80;
  server_name www.southerntours.in;
  location / {
      return 301 https://www.southerntours.in$request_uri;
  }

  location ^~ /.well-known {
      allow all;
      root /home/sasifortrade/st/ssl_cert/;
  }
}

server {
    server_name  southerntours.in;
     return       301 http://www.southerntours.in$request_uri;
}

server {
    listen 443 ssl http2;
    server_name www.southerntours.in;
    client_max_body_size 10M;
    ssl_session_tickets off;
    ssl_stapling on;
    ssl_stapling_verify on;
    ssl_protocols TLSv1.2 TLSv1.1;
    ssl_session_cache shared:SSL:1m; # holds approx 4000 sessions
    ssl_session_timeout 1h; # 1 hour during which sessions can be re-used.
    ssl_prefer_server_ciphers on;
    ssl_buffer_size 4k;
    add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
    add_header X-Frame-Options sameorigin;
    add_header X-Content-Type-Options nosniff;
    add_header X-Xss-Protection "1; mode=block";
    ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
    ssl_certificate /etc/letsencrypt/live/southerntours.in/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/southerntours.in/privkey.pem;

location /secret/cloud/ {
           proxy_set_header X-Real-IP  $remote_addr;
           proxy_set_header Host $host:$server_port;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_pass http://127.0.0.1:8180/;
    }

    location / {
           proxy_pass http://st-ui/;
           include /etc/nginx/mime.types;
    }
    location /sitemap.xml {
           proxy_pass http://st-gateway-server/southern/tours/rest/api/v1/sitemap;
    }
    location /route {
           proxy_pass http://st-gateway-server/;
    }
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #       include snippets/fastcgi-php.conf;
    #
    #       # With php7.0-cgi alone:
    #       fastcgi_pass 127.0.0.1:9000;
    #       # With php7.0-fpm:
    #       fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #       deny all;
    #}
}

0 个答案:

没有答案