Nginx監聽一個端口多域名轉發配置

#user nginx;
worker_processes auto;html

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;nginx

#pid logs/nginx.pid;服務器

events {
worker_connections 1024;
}app

http {
include mime.types;
default_type application/octet-stream;tcp

#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 logs/access.log main;ide

sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
#用服務器IP不能訪問
server {
        listen       80;
        server_name 203.195.211.171;
        error_page 404 401 400  /400.html;
       location / {             
            root   html;
            index 400.html;        
        }
       location = /40x.html{
            root html;
        }
    }
server {
listen 80;
server_name xxx1.com.cn www.xxx1.com;
location / {
proxy_pass http://localhost:8091;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
root html;
index index.html index.htm;
}
}orm

server {
listen 80;
server_name xxx2.com www.xxx2.com;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
root html;
index index.html index.htm;
}
}
}server

相關文章
相關標籤/搜索