```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";
}
}