nginx普通配置/负载均衡配置/ssl/https配置
Posted Ruthless
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx普通配置/负载均衡配置/ssl/https配置相关的知识,希望对你有一定的参考价值。
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配置的主要内容,如果未能解决你的问题,请参考以下文章