码迷,mamicode.com
首页 > Web开发 > 详细

nginx普通配置/负载均衡配置/ssl/https配置

时间:2019-04-09 20:57:53      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:war   tps   pem   roo   share   nginx ssl   ror   cal   str   

1、nginx普通配置
server {
    listen       80;
    server_name  jqlin.lynch.com;
    access_log  /var/log/nginx/main.log  main;
    error_log   /var/log/nginx/pay_local.error;
    #log_format access $remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent $request_body "$http_referer" "$http_user_agent" $http_x_forwarded_for;
    client_max_body_size 60M;
    client_body_buffer_size 512k;
 

    location /apidoc {
        alias  /usr/share/nginx/html/apidoc;
        index  index.html;
    }

    location / {
        proxy_pass http://172.16.92.255:8091; # 172.16.92.255为局域网IP,不行用localhost/127.0.0.1替代   
        proxy_redirect  off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
     
}


2、nginx负载均衡配置
upstream mysite {
    server 172.16.92.255:8092 weight=5; # 172.16.92.255为局域网IP,不行用localhost/127.0.0.1替代   
    server 172.16.92.255:8091 weight=5; # 172.16.92.255为局域网IP,不行用localhost/127.0.0.1替代   
}
 
server {
    listen 80;
    server_name jqlin.lynch.com www.jqlin.lynch.com;
    access_log  /var/log/nginx/main.log  main;
    error_log   /var/log/nginx/pay_local.error;
    client_max_body_size 60M;
    client_body_buffer_size 512k;

    location /apidoc {
        alias  /usr/share/nginx/html/apidoc;
        index  index.html;
    }
        
    location / {
        proxy_pass http://mysite;
    }
}

3、nginx ssl/https配置
server {
    listen       80;
    server_name www.jqlin.lynch.com jqlin.lynch.com;
    error_log   /usr/share/nginx/html/test/pay_local.error;
    client_max_body_size 60M;
    client_body_buffer_size 512k;
    
    location / {   
        root   /usr/share/nginx/html/kshop;
        index  index.html;
        autoindex  on;
    }
    
}

server {
    listen       443    ssl;
    server_name www.jqlin.lynch.com jqlin.lynch.com;
    error_log   /usr/share/nginx/html/test/pay_local.error;
    client_max_body_size 60M;
    client_body_buffer_size 512k;
    
    location / {
                root   /usr/share/nginx/html/kshop;
                index  index.html;
                autoindex  on;
    }
    
    ssl_certificate /etc/nginx/conf.d/fullchain.pem;
    ssl_certificate_key /etc/nginx/conf.d/privkey.pem;
}

 

nginx普通配置/负载均衡配置/ssl/https配置

标签:war   tps   pem   roo   share   nginx ssl   ror   cal   str   

原文地址:https://www.cnblogs.com/linjiqin/p/10679331.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!