你现在的位置: 导航首页 > 技术文章
技术精华文章win环境vpn安装nginx配置说明Win系统CMD命令CentOS系统SSH命令Linux下安装pptpdLinux下安装nginx

    nginx.conf配置说明


主要配置步骤

用#号注释说明

worker_processes 2;  #线程数
events {
    worker_connections  1024;   #单线程连接数
}
http {
    include       mime.types;    #引入模块
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    gzip on;                   #开启压缩,否则off
   gzip_proxied any;
   gzip_min_length  1024;
   gzip_buffers     4 8k;  
   gzip_comp_level 9;  
   gzip_http_version 1.1; 
   
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php    image/jpeg image/gif image/png;
    #设定实际的服务器列表 
    upstream gdgj_server_port {
        server 119.3.237.42:8076;
    }
    upstream hsy3_server_port {
        server 119.3.237.42:8078;
    }
    server {
        listen 81 default;
		
        server_name _;
		
        location / {
	root  html/50x.html;
        index index.html index.htm;
		
    }
}
server {
        listen       80;
        server_name  abc.fq98.com;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            root   D:\huashi_www_web\idc;
            index  Default.htm index.html;
        }
    }
server {
        listen       80;
        server_name  abc.net.cn;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            proxy_set_header Host  $host;
            proxy_set_header X-Forwarded-For  $remote_addr;
            # proxy_cache_key "$scheme$host$request_uri";
            proxy_pass  http://gdgj_server_port;
            expires 5m;
        }
        location ~ .*\.(htm|html|js|css|gif|jpg|jpeg|png|bmp|swf|flv|exe|zip|rar|7z)$
        {
            proxy_pass http://gdgj_server_port;
            expires 5m;
            proxy_cache_valid 200 302 1h;
            proxy_cache_valid 301 1d;
            proxy_cache_valid any 1m;
            proxy_set_header Host  $host;
            proxy_set_header X-Forwarded-For  $remote_addr;
        }
    }
        # HTTPS server
    
    server {
        listen       443 ssl;
        server_name  ssl.fq98.com;
        ssl_certificate      www_key/3104497_ssl.fq98.com.pem;
        ssl_certificate_key  www_key/3104497_ssl.fq98.com.key;
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;
        ssl_ciphers  ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers  on;
        location / {
            proxy_pass http://119.3.237.42:30033;
        }
    }
    server {
        listen       443 ssl;
        server_name  hsy3.com www.abc.com;
        ssl_certificate      www_key/3097058_abc.com.pem;
        ssl_certificate_key  www_key/3097058_abc.com.key;
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;
        ssl_ciphers  ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers  on;
        location / {
            proxy_set_header Host  $host;
            proxy_set_header X-Forwarded-For  $remote_addr;
            # proxy_cache_key "$scheme$host$request_uri";
            proxy_pass  http://hsy3_server_port;
            expires 5m;
        }
        location ~ .*\.(htm|html|js|css|gif|jpg|jpeg|png|bmp|swf|flv|exe|zip|rar|7z)$
        {
            proxy_pass http://hsy3_server_port;
            expires 5m;
            proxy_cache_valid 200 302 1h;
            proxy_cache_valid 301 1d;
            proxy_cache_valid any 1m;
            proxy_set_header Host  $host;
            proxy_set_header X-Forwarded-For  $remote_addr;
        }
    }
}