1.更改nginx.conf,加入以下两行
include upstream.conf;
include D:/softkit/nginx-1.8.1/conf/server/*.conf;
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
charset utf-8;
#root html;
#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;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
######加入以下两行######
include upstream.conf;
include D:/softkit/nginx-1.8.1/conf/server/*.conf;
}
2.找到上述新建路径,更改或添加工程内容
sellerwap工程
server {
listen 80;
server_name m.seller.dhgate.com;
HIGH:!aNULL:!eNULL:!ECDH:!MD5:!RC4:!PSK:!DES:!EXPORT:!EDH:!DHE:!ECDH:!ECDHE;
##ssl_prefer_server_ciphers on;
proxy_buffer_size 64k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 128k;
userid on;
userid_name vid;
userid_expires 1000d;
userid_domain dhgate.com;
add_header srv_id $upstream_addr ;
set $www_dhgate_auth "";
if ( $http_cookie ~* "vid=([^;]+)" ){
set $www_dhgate_auth $1;
}
set $trueip_aka $remote_addr;
set $xc_realip $http_XC_Proxy_Real_IP;
set $xc_domain $http_XC_Proxy_Request_Domain;
set $xc_locale $http_XC_Proxy_Locale;
if ( $http_true_client_ip != "" ){
set $user_ipaddr $http_true_client_ip;
}
if ( $http_true_client_ip = "" ){
set $user_ipaddr $remote_addr;
}
access_log D:/softkit/nginx-1.8.1/logs/nginxlog/seller_wap_access.log ;
location / {
index index.html index.htm;
root D:/data/www/m.seller.dhgate.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;
}
location /sellerwap {
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://sellerwap;
}
}
跑多个工程和上述步骤一致
3.更改upstream.conf
upstream dhport-dhgate-com {
ip_hash;
server 192.168.223.56:7777;
}
upstream sellerwap {
server 192.168.74.27:9091;
}
upstream syi {
server 192.168.74.27:9094;
}
4.新建主页地址,与sellerwap.conf保持一致
重启nginx.exe
nginx -s reload
最后同时启动自己配置的多个项目就可以了!!