update
This commit is contained in:
parent
7d468e8b73
commit
7d9652c3dc
14
Dockerfile
14
Dockerfile
@ -63,7 +63,7 @@ RUN if [ "${NODE_ENV}" = "production" ]; then \
|
|||||||
FROM nginx:stable-alpine as production-stage
|
FROM nginx:stable-alpine as production-stage
|
||||||
|
|
||||||
# 安装基础工具
|
# 安装基础工具
|
||||||
RUN apk add --no-cache bash curl
|
RUN apk add --no-cache bash curl net-tools iputils
|
||||||
|
|
||||||
# 创建必要的目录并设置权限
|
# 创建必要的目录并设置权限
|
||||||
RUN mkdir -p /var/cache/nginx/client_temp && \
|
RUN mkdir -p /var/cache/nginx/client_temp && \
|
||||||
@ -95,6 +95,16 @@ RUN chown -R nginx:nginx /var/cache/nginx && \
|
|||||||
chmod -R 755 /usr/share/nginx/html && \
|
chmod -R 755 /usr/share/nginx/html && \
|
||||||
chmod -R 755 /etc/nginx/conf.d
|
chmod -R 755 /etc/nginx/conf.d
|
||||||
|
|
||||||
|
# 创建启动脚本
|
||||||
|
RUN echo '#!/bin/sh\n\
|
||||||
|
echo "=== 容器网络信息 ==="\n\
|
||||||
|
ip addr\n\
|
||||||
|
echo "=== Nginx 配置检查 ==="\n\
|
||||||
|
nginx -t\n\
|
||||||
|
echo "=== 启动 Nginx ==="\n\
|
||||||
|
nginx -g "daemon off;"\n\
|
||||||
|
' > /start.sh && chmod +x /start.sh
|
||||||
|
|
||||||
# 暴露端口
|
# 暴露端口
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
@ -102,4 +112,4 @@ EXPOSE 80
|
|||||||
USER root
|
USER root
|
||||||
|
|
||||||
# 启动nginx
|
# 启动nginx
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["/start.sh"]
|
||||||
@ -1,6 +1,6 @@
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name localhost;
|
server_name localhost _; # 添加通配符,接受任何域名
|
||||||
|
|
||||||
# 添加 gzip 压缩
|
# 添加 gzip 压缩
|
||||||
gzip on;
|
gzip on;
|
||||||
@ -16,6 +16,10 @@ server {
|
|||||||
location / {
|
location / {
|
||||||
try_files $uri $uri/ /index.html;
|
try_files $uri $uri/ /index.html;
|
||||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||||
|
# 添加跨域支持
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
|
||||||
}
|
}
|
||||||
|
|
||||||
# 缓存静态资源
|
# 缓存静态资源
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user