nginx配置

Posted CTO老王

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx配置相关的知识,希望对你有一定的参考价值。

worker_processes 4;
error_log logs/error.log crit; #日志位置和日志级别
pid logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# include /usr/local/nginx/conf/url.conf;
upstream backend {
#ip_hash;
server 172.17.0.3:8080 weight=1 max_fails=2 fail_timeout=2;
server 172.17.0.4:8080 weight=1 max_fails=2 fail_timeout=2;
}
server {

listen 80;

server_name localhost;
ssl on;
root html;
index index.html index.htm;
ssl_certificate cert/214031620150360.pem;
ssl_certificate_key cert/214031620150360.key;
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 / {

#设置主机头和客户端真实地址,以便服务器获取客户端真实IP

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_buffering off;

#反向代理的地址

proxy_pass http://backend;
}
location /sup {
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;
proxy_pass http://172.17.0.5:8080/sup;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_buffer_size 64k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_ignore_client_abort on;
}
location /settle {
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;
proxy_pass http://172.17.0.6:8080/settle;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_buffer_size 64k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_ignore_client_abort on;
}

 


}
}

以上是关于nginx配置的主要内容,如果未能解决你的问题,请参考以下文章

nginx配置

nginx启动与配置

如何用nginx.conf配置nginx

nginx如何配置代理

nginx常用配置

nginx安装和常见的配置