Browse Source

114服务器部署

heavyrain 5 days ago
parent
commit
ac6eebb16f
3 changed files with 30 additions and 6 deletions
  1. 1 0
      Dockerfile
  2. 3 3
      docker-compose.yml
  3. 26 3
      nginx/nginx.conf

+ 1 - 0
Dockerfile

@@ -5,4 +5,5 @@ COPY ./nginx/cert/trane.trane-optimizer.com.cn.key /etc/nginx/cert/trane.trane-o
 COPY ./nginx/cert/trane.trane-optimizer.com.cn.pem /etc/nginx/cert/trane.trane-optimizer.com.cn.pem
 
 # nginx:1.27
+# registry.cn-hangzhou.aliyuncs.com/jianboy/nginx:1.27.1
 

+ 3 - 3
docker-compose.yml

@@ -2,21 +2,21 @@ services:
 
   frontend:
     container_name: frontend
-    image: trane-tech-energy-strategy-optimization-platform-frontend:v1.0
+    image: registry.cn-hangzhou.aliyuncs.com/jianboy/trane-tech-energy-strategy-optimization-platform-frontend:v1.0
     ports:
       - 8091:80
     restart: unless-stopped
 
   backend:
     container_name: backend
-    image: trane-tech-energy-strategy-optimization-platform-backend:v1.0
+    image: registry.cn-hangzhou.aliyuncs.com/jianboy/trane-tech-energy-strategy-optimization-platform-backend:v1.0
     ports:
       - 8092:8082
     restart: unless-stopped
 
   nginx:
     container_name: nginx
-    image: nginx:1.27
+    image: registry.cn-hangzhou.aliyuncs.com/jianboy/nginx:1.27.1
     ports:
       - 80:80
       - 443:443

+ 26 - 3
nginx/nginx.conf

@@ -1,13 +1,36 @@
 server {
     listen 80;
 
-    server_name trane.trane-optimizer.com.cn;
-    return 301 https://trane.trane-optimizer.com.cn$request_uri;
+     location / {
+        proxy_pass http://frontend:80;  
+        proxy_set_header Host $host;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+        proxy_set_header X-Forwarded-Proto $scheme;
+    }
+
+    location ^~ /api/ {
+    proxy_pass http://backend:8082/;
+    proxy_set_header Host $host;
+    proxy_set_header X-Real-IP $remote_addr;
+    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    proxy_set_header X-Forwarded-Proto $scheme;
+    proxy_set_header REMOTE-HOST $remote_addr;
+    proxy_http_version 1.1;
+    add_header X-Cache $upstream_cache_status;
+    set $static_fileTU7903MC 0;
+    if ($uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$") {
+        set $static_fileTU7903MC 1;
+        expires 1m;
+    }
+        if ($static_fileTU7903MC = 0) {
+            add_header Cache-Control no-cache;
+        }
+    }
 }
 
 server {
     listen 443 ssl;
-    server_name trane.trane-optimizer.com.cn;
 
     ssl_certificate /etc/nginx/cert/trane.trane-optimizer.com.cn.pem;
     ssl_certificate_key /etc/nginx/cert/trane.trane-optimizer.com.cn.key;