From 10b8e752636b2d13bc484803fd9a790fe246935f Mon Sep 17 00:00:00 2001 From: AaGMixW Date: Fri, 10 Feb 2023 17:32:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20websocket=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E3=80=81=E4=BC=98=E5=85=88=E4=BD=BF=E7=94=A8=E9=95=9C=E5=83=8F?= =?UTF-8?q?=E8=80=8C=E4=B8=8D=E6=98=AF=E9=87=8D=E6=96=B0=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E3=80=81=E7=AB=AF=E5=8F=A3=E4=BF=AE=E6=94=B9=E3=80=81=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E5=90=8D=E7=A7=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 3 -- .gitignore | 7 ++-- docker-compose.yml | 8 +++- service/Dockerfile | 4 ++ service/config/application-prod.yml | 6 +-- web/Dockerfile | 5 ++- web/conf.d/default.conf | 58 ++++++++++++++++++++--------- 7 files changed, 62 insertions(+), 29 deletions(-) diff --git a/.dockerignore b/.dockerignore index d78ef07..3dbbcf3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -21,8 +21,5 @@ **/obj **/secrets.dev.yaml **/values.dev.yaml -**/*.jar -service/opt/ -web/html/ LICENSE README.md diff --git a/.gitignore b/.gitignore index f1c8e72..3f1dad1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ -**/*.jar -service/opt/ -web/html/ \ No newline at end of file +service/*.jar +service/data/ +web/html/ +images \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 826c3d0..646a270 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,11 +2,15 @@ version: '2' services: military-system: build: service + image: military_system + container_name: military_system restart: on-failure ports: - - 8080:8080 + - 8049:8049 military-web: build: web + image: military_system_web + container_name: military_system_web restart: on-failure ports: - - 8089:8089 \ No newline at end of file + - 3001:3001 \ No newline at end of file diff --git a/service/Dockerfile b/service/Dockerfile index dbae733..590c0da 100644 --- a/service/Dockerfile +++ b/service/Dockerfile @@ -6,6 +6,9 @@ # 基础镜像 FROM openjdk:8-jdk-alpine +LABEL Author="bb, aagmix" +LABEL VERSION="1.0" + VOLUME [ "/data" ] ARG JAVA_OPTS @@ -15,6 +18,7 @@ ENV JAVA_OPTS=$JAVA_OPTS # 从当前工作目录复制文件到镜像目录中并重新命名 COPY config /military/config +COPY data /data COPY military.jar /military/military.jar # 执行Linux命令,运行jar包 diff --git a/service/config/application-prod.yml b/service/config/application-prod.yml index 640466e..205f723 100644 --- a/service/config/application-prod.yml +++ b/service/config/application-prod.yml @@ -1,5 +1,5 @@ server: - port: 8080 + port: 8049 tomcat: max-swallow-size: -1 error: @@ -187,9 +187,9 @@ jeecg: uploadType: local path: #文件上传根目录 设置 - upload: /opt/upFiles + upload: /data/upFiles #webapp文件路径 - webapp: /opt/webapp + webapp: /data/webapp shiro: excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/** #阿里云oss存储和大鱼短信秘钥配置 diff --git a/web/Dockerfile b/web/Dockerfile index c6515ed..91d8ece 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -6,6 +6,9 @@ # 基础镜像 FROM nginx +LABEL Author="bb, aagmix" +LABEL VERSION="1.0" + # config COPY nginx.conf /etc/nginx COPY conf.d /etc/nginx/conf.d @@ -13,6 +16,6 @@ COPY conf.d /etc/nginx/conf.d COPY html /usr/share/nginx/html # 暴露端口 -EXPOSE 8089 +EXPOSE 3001 CMD "nginx" "-g" "daemon off;" \ No newline at end of file diff --git a/web/conf.d/default.conf b/web/conf.d/default.conf index 31f2cfb..5a28b02 100644 --- a/web/conf.d/default.conf +++ b/web/conf.d/default.conf @@ -1,21 +1,45 @@ +map $http_upgrade $connection_upgrade { + default upgrade; + '' close; +} + +upstream back_end { + server military-system:8049; # appserver_ip:ws_port +} + server { - listen 8089; - listen [::]:8089; + listen 3001; + listen [::]:3001; server_name localhost; + # 后台服务配置,配置了这个location便可以通过访问 - location ^~ /military { - proxy_pass http://military-system:8080/military/; - proxy_set_header Host $host:8089; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } - #解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题 - location / { - root /usr/share/nginx/html; - index index.html index.htm; - if (!-e $request_filename) { - rewrite ^(.*)$ /index.html?s=$1 last; - break; - } - } + location ^~ /military { + proxy_pass http://back_end/military/; + proxy_set_header Host $host:3001; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + location ^~ /military/websocket { + proxy_pass http://back_end/military/websocket/; + proxy_read_timeout 300s; + proxy_send_timeout 300s; + + proxy_set_header Host $host:3001; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + } + } + + #解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题 + location / { + root /usr/share/nginx/html; + index index.html index.htm; + if (!-e $request_filename) { + rewrite ^(.*)$ /index.html?s=$1 last; + break; + } + } } \ No newline at end of file