nginx的使用

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
最后同时启动自己配置的多个项目就可以了!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值