From 1207a4235539467240b5ddb7e357a79643979c07 Mon Sep 17 00:00:00 2001 From: liuchen864 <23082234@qq.com> Date: Thu, 7 Mar 2024 11:37:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9nginx=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 9 ++++----- nginx.conf => default.conf | 8 ++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) rename nginx.conf => default.conf (83%) diff --git a/Dockerfile b/Dockerfile index 2ec690981..8224a88ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ -# 设置基础镜像 -FROM nginx:WIN-1.25.3 - +FROM nginx WORKDIR /opt/sfms3.0 -COPY nginx.conf /usr/local/nginx/conf/nginx.conf -# 将dist文件中的内容复制到 /opt/sfms3.0 这个目录下面 +RUN rm /etc/nginx/conf.d/default.conf +ADD default.conf /etc/nginx/conf.d/ +# 将sfms3.0文件中的内容复制到 /opt/sfms3.0 这个目录下面 COPY sfms3.0/ /opt/sfms3.0 diff --git a/nginx.conf b/default.conf similarity index 83% rename from nginx.conf rename to default.conf index c2afefb0f..baea1d58d 100644 --- a/nginx.conf +++ b/default.conf @@ -12,6 +12,8 @@ http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" "$request_time $upstream_response_time"'; + + proxy_cache_path /opt/nginx_cache/ levels=1:2 keys_zone=my_zone:10m inactive=300s max_size=5g; access_log logs/access.log main; sendfile on; #tcp_nopush on; @@ -40,10 +42,16 @@ http { proxy_set_header X-Forwarded-For $http_x_forwarded_for; } location /profile/ { + proxy_cache my_zone; + proxy_cache_valid 200 304 12h; + proxy_cache_key $host$uri$is_args$args; alias /opt/profile/; index index.html index.htm; } location / { + proxy_cache my_zone; + proxy_cache_valid 200 304 12h; + proxy_cache_key $host$uri$is_args$args; try_files $uri $uri/ /index.html; root /opt/sfms3.0; index index.html index.htm;