• 周四. 12月 1st, 2022

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

nginx分流配置

admin

11月 28, 2021
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;
geo $remote_addr $geo {
     default 0;
#     10.0.0.66/32 1;
     10.0.0.65/32 2;
     10.0.0.0/24 3;
  }
upstream server_65 {
  server 10.0.0.65:80;
  }
upstream server_66 {
  server 10.0.0.66:80;
  }
server {
     listen      80 default_server;
     listen       [::]:80 default_server;
     server_name  _;
     root         /usr/share/nginx/html;
    if ($geo = 1) {
        #return 200 'this is for 10.0.0.66';
        proxy_pass http://server_66;
        }
    if ($geo = 2) {
        #return 200 'this is for 10.0.0.65';
        proxy_pass http://server_65;
        }
    if ($geo = 3) {
        #return 200 'this is for 10.0.0.0/24';
           }

.zstitle { 280px; text-align: center; font-size: 16px }
.zsimgweixin { 280px }
.zsimgali { 280px; padding: 0px 0px 50px 0px }
.zsleft { float: left }
.zsdiv { display: flex; justify-content: center;}
.zs { font-size: 26px }
.zspaddingright { padding: 0px 100px 0px 0px }

微信赞赏


支付宝赞赏

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注