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

原文链接: http://www.cnblogs.com/linjiqin/p/10679331.html
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;
}

 

转载于:https://www.cnblogs.com/linjiqin/p/10679331.html

你可能感兴趣的:(nginx普通配置/负载均衡配置/ssl/https配置)