nginx配置路由转发


获取ngxin

docker pull hub.deri.org.cn/library/nginx

编写nginx.conf

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 taskservice{
        server 172.16.0.9:28080;
    }

    upstream authservice{
        server 172.16.0.9:25050;
    }

    upstream dbcservice{
        server 172.16.0.9:28082;
    }

    upstream hbcservice{
        server 172.16.0.9:26060;
    }

    upstream graphservice{
        server 172.16.0.9:29090;
    }

    server {
        listen    80 default_server;
        server_name _;
    location /ts {
        proxy_pass    http://taskservice;
    }
        location /auth {
            proxy_pass  http://authservice;
        }
        location /dbc {
            proxy_pass  http://dbcservice;
        }
        location /hbc {
            proxy_pass  http://hbcservice;
        }
        location /graph {
            proxy_pass  http://graphservice;
        }
    }
}

启动nginx容器

docker run -d --name nginx  -p 8080:80 -v /root/nginx/nginx.conf:/etc/nginx/nginx.conf  nginx

文章作者: wuzhiyong
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 wuzhiyong !
评论
 上一篇
linux设置swap linux设置swap
查看swap状态[root@ecs ~]# free -m total used free shared buff/cache available Mem:
2020-12-04
下一篇 
semaphore信号量使用 semaphore信号量使用
锁的说明java中锁有Synchronized、ReentrantLock,但是这两种锁一次只能允许一个线程访问资源,而信号量semaphore可以控制多个线程同时获取资源,实现更高级别的限流. semaphore使用// 创建信号量,pe
2020-12-04
  目录