Skip to content

Commit

Permalink
chore: use env in nginx conf
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Nov 21, 2022
1 parent 0a23d0e commit 2fc2a67
Show file tree
Hide file tree
Showing 3 changed files with 13,367 additions and 13,883 deletions.
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@ RUN npm config set registry https://registry.npmmirror.com
RUN yarn config set registry https://registry.npmmirror.com
RUN yarn install

EXPOSE 4201 4202
EXPOSE $NODE_SERVER_PORT $EOAPI_WEBSOCKET_POST

CMD ["yarn", "start:all"]


FROM nginx:alpine as production

ENV NODE_ENV production
# 远程服务端口
ENV EOAPI_SERVER_PORT 3000
# api 测试服务端口
ENV NODE_SERVER_PORT 4201
# websocket 测试服务端口
ENV EOAPI_WEBSOCKET_POST 4202

COPY ./src/workbench/browser/dist/ /usr/share/nginx/html
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
COPY ./default.conf.template /etc/nginx/templates/

EXPOSE 80
8 changes: 4 additions & 4 deletions nginx.conf → default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ server {

# api测试服务
location /api/unit {
proxy_pass http://eoapi-test-server:4201; # 转发规则
proxy_pass http://eoapi-test-server:$NODE_SERVER_PORT; # 转发规则
proxy_set_header Host $proxy_host; # 修改转发请求头,让3000端口的应用可以受到真实的请求
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

# websocket测试服务
location ~/socket.io/(.*) {
proxy_pass http://eoapi-test-server:4202; # 转发规则
proxy_pass http://eoapi-test-server:$EOAPI_WEBSOCKET_POST; # 转发规则

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
Expand All @@ -58,15 +58,15 @@ server {

# 后端服务
location ^~ /api {
proxy_pass http://eoapi-remote-server:3000; # 转发规则
proxy_pass http://eoapi-remote-server:$EOAPI_SERVER_PORT; # 转发规则
proxy_set_header Host $proxy_host; # 修改转发请求头,让3000端口的应用可以受到真实的请求
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

# 后端服务兼容旧客户端
location ~ ^/(system|workspace|user|auth|mock|[0-9]+/[0-9]+/api_data|[0-9]+/[0-9]+/group|[0-9]+/[0-9]+/group|[0-9]+/[0-9]+/environment|[0-9]+/[0-9]+/api_test_history|[0-9]+/[0-9]+/mock|[0-9]+/[0-9]+/shared|[0-9]+/project) {
proxy_pass http://eoapi-remote-server:3000; # 转发规则
proxy_pass http://eoapi-remote-server:$EOAPI_SERVER_PORT; # 转发规则
proxy_set_header Host $proxy_host; # 修改转发请求头,让3000端口的应用可以受到真实的请求
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down
Loading

0 comments on commit 2fc2a67

Please sign in to comment.