【nginx 文件目录挂载 docker版】

在这里插入图片描述
在这里插入图片描述

```bash
 nginx:
    image: ${NGINX_TAG}
    container_name: nginx
    restart: always
    profiles:
      - user-interface
    ports:
      - "80:80"
    environment:
      WMS_APP_HOST: ${WMS_APP_HOST}
    volumes:
      - /etc/hosts:/etc/hosts
      - ./core-web:/usr/share/nginx/html
      - ./nginx/template:/etc/nginx/templates
      - /home/lianhe/lianhe:/home/lianhe/lianhe

在这里插入图片描述

log_format trace
    '[$time_local] '
    '"$request" $status $body_bytes_sent '
    '"$http_referer"'
    '"$http_x_forwarded_for" $request_id';

upstream core-main-web {
    server core-web:80;
}

upstream core-main-api {
    server lianhe-core:8082;
}

upstream core-rss-api {
    server lianhe-core:9000;
}

upstream core-rss-client {
    server lianhe-core:8080;
}

upstream core-wms-api {
    server lianhe-core:8083;
}

upstream core-mdy {
    server lianhe-core:8880;
}

server {
    listen 80;
    # gzip config
    gzip on;
    gzip_min_length 1k;
    gzip_comp_level 9;
    gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";
    client_max_body_size 1024m;
    # add_header 'Access-Control-Allow-Origin' $http_origin;
    # add_header 'Access-Control-Allow-Credentials' 'true';
    # add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
    # add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
    # if ($request_method = 'OPTIONS') {
    #    add_header 'Access-Control-Allow-Origin' $http_origin;
    #   add_header 'Access-Control-Allow-Credentials' 'true';
    #   add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
    #   add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
    #   add_header 'Access-Control-Max-Age' 1728000;
    #   add_header 'Content-Type' 'text/plain charset=UTF-8';
    #   add_header 'Content-Length' 0;
    #   return 204;
    # }
    location / {
#         root /usr/share/nginx/html;
#         try_files $uri $uri/ /index.html;
        proxy_pass http://core-main-web/;
    }
 location /rss-log {
       alias /home/lianhe/lianhe/core-rss/log;
       autoindex on;
       autoindex_exact_size off;
       autoindex_localtime on;
   }

   location /agv-log {
       alias /home/lianhe/lianhe/core-rss/agvLog;
       autoindex on;
       autoindex_exact_size off;
       autoindex_localtime on;
   }

    location /api/v1/ {
        add_header 'Access-Control-Allow-Origin' $http_origin;
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
        add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
        if ($request_method = 'OPTIONS') {
            add_header 'Access-Control-Allow-Origin' $http_origin;
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
            add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'text/plain charset=UTF-8';
            add_header 'Content-Length' 0;
            return 204;
        }
        proxy_pass http://core-main-api/api/v1/;
     #  proxy_pass http://lianhe-core:8082/api/v1;
    }

    #location /api/v1/rss/scene/[\d]+/map/ {
    #   proxy_pass http://core-rss-api/api/map/;
    #}

    location /api/v1/rss/ {
	add_header 'Access-Control-Allow-Origin' $http_origin;
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
        add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
        if ($request_method = 'OPTIONS') {
            add_header 'Access-Control-Allow-Origin' $http_origin;
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
            add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'text/plain charset=UTF-8';
            add_header 'Content-Length' 0;
            return 204;
        }
        rewrite ^/api/v1/rss/scene/(\d+)/map/(.*)$ /api/map/$2 break;
        rewrite ^/api/v1/rss/scene/(\d+)/slam/(.*)$ /api/slam/$2 break;
        rewrite ^/api/v1/rss/scene/(\d+)/robot/(.*)$ /api/robot/$2 break;
        rewrite ^/api/v1/rss/scene/(\d+)/freePoint/(.*)$ /api/freePoint/$2 break;
        rewrite ^/api/v1/rss/scene/(\d+)/chargeStation/(.*)$ /api/chargeStation/$2 break;
        rewrite ^/api/v1/rss/scene/(\d+)/task/(.*)$ /api/task/$2 break;
        proxy_pass http://core-rss-api/api/;
    }

    location /api/v1/wms/ {
        add_header 'Access-Control-Allow-Origin' $http_origin;
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
        add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
        if ($request_method = 'OPTIONS') {
            add_header 'Access-Control-Allow-Origin' $http_origin;
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
            add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'text/plain charset=UTF-8';
            add_header 'Content-Length' 0;
            return 204;
        }
        proxy_pass http://core-wms-api/api/v1/;
    }

    location /scene/ {
        rewrite ^/scene/(\d+)/map/plan /map/plan break;
        proxy_pass http://core-rss-client/;
    }

    location /api/ws {
        proxy_pass http://core-rss-api/api/ws;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    location /mdy {
        set $real_ip '';
        if ($http_x_real_ip) {
            set $real_ip $http_x_real_ip;
        }
        if ($http_x_real_ip = '') {
            set $real_ip $remote_addr;
        }
        proxy_set_header X-Real-IP $real_ip;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://192.168.1.38:8880;
    }

    location /mdy/mds2 {
        proxy_set_header Host $http_host;
        proxy_hide_header X-Powered-By;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass http://192.168.1.38:8880;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection upgrade;
    }

    location /api/v1/wcs {
    	proxy_pass http://lianhe-core:1880;
    }

    location /api/wcs/ws {
        proxy_pass http://lianhe-core:1880/log;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }


}

在这里插入图片描述

  • 21
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值