nginx简单配置
Posted 一个大洋葱
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx简单配置相关的知识,希望对你有一定的参考价值。
这里主要是配置upstream和server,其他的都没动,默认是服务器轮询方式主要目的是用于测试
user nginx;
worker_processes 1;
error_log /var/log/nginx/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 "$http_referer" ‘
‘"$http_user_agent" "$http_x_forwarded_for"‘;
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
upstream servers.mydomain.com{
server 192.168.233.128:8080;
server 192.168.233.129:8080;
server 192.168.233.131:8080;
}
server{
listen 80;
server_name www.mydomain.com;
location / {
proxy_pass http://servers.mydomain.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
以上是关于nginx简单配置的主要内容,如果未能解决你的问题,请参考以下文章