IIS 转发Nginx 报504 Gateway Time-out 原因及解决方法

转发Nginx 报504 Gateway Time-out 想把域名单独设置为SSL,但是设置之后,其他网址无法访问443端口,应该是IIS绑定443端口之后,Nginx无法访问,因此此方法无效

 

需要从继续在Nginx的配置文件上下功夫,修改nginx.conf中的配置

 

一、添加fastcgi配置文件

worker_processes  1;

events { 
    worker_connections  51200; #修改配置,原来是1024
}


http {
    include       mime.types;
    default_type  application/octet-stream;

        server_names_hash_bucket_size 512;  #新增配置
        client_header_buffer_size 32k;  #新增配置
        large_client_header_buffers 4 32k;  #新增配置
        client_max_body_size 50m;  #新增配置
    
        sendfile        on;
        keepalive_timeout  65;

        fastcgi_connect_timeout 300;  #新增配置
        fastcgi_send_timeout 300;   #新增配置
        fastcgi_read_timeout 300;   ##新增配置
        fastcgi_buffer_size 64k;  #新增配置  
        fastcgi_buffers 4 64k;  #新增配置
        fastcgi_busy_buffers_size 128k;  #新增配置
        fastcgi_temp_file_write_size 256k; #新增配置
  fastcgi_intercept_errors on;

  

二、域名转发的端口后面添加请求和读超时时间

 

server {
        listen 443;
        server_name  www.yourweb.com;
        ssl_certificate      ../ssl/www.yourweb.com.pem;
        ssl_certificate_key  ../ssl/www.yourweb.com.key;
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!3DES:!MD5:!ADH:!RC4:!DH:!DHE;
          
    ssl_prefer_server_ciphers on;
        location / {
            root /;
            index /;
      proxy_pass http://localhost:8004;
      
      proxy_set_header Host $host;
      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_connect_timeout 300; #原来默认是1,改成300
      proxy_read_timeout 300;  #原来默认是1,改成300
      proxy_send_timeout 300;  #原来默认是1,改成300
        }

  

上一篇:WIN7下怎么安装iis教程


下一篇:.NetCore项目在IIS中部署