nginx配置

主配置文件 /etc/nginx/nginx.conf

 

这里的问题,配置以后速度非常慢,http和https都慢。
猜测原因:
1.Nginx运行的时候是nginx账号。证书是root用户的,切换chown以后好了。
2.服务器提供商网络问题

server {  
            listen 80;  
            listen 443 ssl;  
            server_name www.*.cn;  
          
            #ssl on;   //这行必须要注释掉  
            ssl_certificate /usr/local/nginx/conf/zou_lu.crt;  
            ssl_certificate_key /usr/local/nginx/conf/zoulukey.pem;  
 }  

 

user  nginx;
worker_processes  1;
 
error_log  /work/nginx/log/error.log warn;
pid        /var/run/nginx.pid;
 
 
events {
    worker_connections  1024;
}
 
 
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
 
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent $request_body "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" "$http_cookie"';
 
    access_log  /work/nginx/log/access.log  main;
 
    sendfile        on;
    #tcp_nopush     on;
 
    keepalive_timeout  65;
    
    limit_req_zone  $cookie_token zone=session_limit:10m rate=10r/s;
    limit_req_zone  $binary_remote_addr zone=auth_limit:3m rate=1r/s;
    limit_req_zone  $binary_remote_addr zone=dynamic_limit:10m rate=5r/s;
    #gzip  on;
 
    include /etc/nginx/conf.d/*.conf;
}

 

 

 

主配置中include的conf文件

 

upstream webservice{
    server 192.168.232.x:19100;
    server 192.168.232.x:19100;
}
 
upstream ent_webservice{
    server 192.168.232.x:19101;
}
 
upstream patent_webservice{
    server 192.168.232.x:19101;
}
 
server {
    listen       80;
    server_name  [域名];
 
    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;
    
    location / {
        root   /work/nginx/www;
        index  index.html index.htm;
    }
 
    location /auth {
        limit_req zone=auth_limit burst=1;
        if ($arg_url = "") {
            return 403;
        }
 
        access_by_lua '
            local random = math.random(9999)
            local token = ngx.md5("kc" .. ngx.var.remote_addr .. random)
            if (ngx.var.cookie_token ~= token) then
                ngx.header["Set-Cookie"] = {"token=" .. token, "random=" .. random}
                return ngx.redirect(ngx.var.arg_url)
            end
        ';
    }
 
    location ^~ /kc_webservice/ {
        proxy_pass  http://webservice;
    }
 
    #websocket
    location ^~ /kc_chat/chat/ {
        proxy_pass http://192.168.232.x:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }
    
    location ^~ /SSE_ENT/ {
        proxy_pass http://ent_webservice;
    }
 
    location ^~ /SSE_Patent/ {
        proxy_pass http://patent_webservice;
    }       
 
 
    #error_page  404              /404.html;
 
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
 
    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}
 
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}
 
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
 
 #配置子域名转发
server {
    listen       80;
    server_name  [子域名];
 
    location / {
        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_pass http://192.168.232.x:8080;
    }
} 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值