nginx 设置多项目代理转发

user  nginx;
worker_processes  2;
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;
    # 最大上传文件大小限制
    client_max_body_size 20M;

    #gzip  on;

    #include /etc/nginx/conf.d/*.conf;

    server {
    listen       80;
    server_name  192.168.1.123;

    #将/请求转发给http://127.0.0.1:8083/处理
    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:8083;
    }
    #将/project请求转发给http://127.0.0.1:8084/project处理
    location /project {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:8084/project;
    }
    }
}

posted @ 2020-12-14 17:14  大手牵小手  阅读(611)  评论(0)    收藏  举报