Nginx基础镜像打包
温馨提示:
本文最后更新于 2025年05月30日,已超过 379 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我。
Nginx基础镜像打包
FROM nginx:1.27.0
LABEL maintainer="lalala"
# 设置时区为上海东八区
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" >/etc/timezone
# nginx 将编译生成的dist下的文件复制到容器/usr/share/nginx/html中
COPY dist/ /usr/share/nginx/html/myproject-vue/
# 复制nginx配置文件到容器/etc/
COPY nginx.conf /etc/nginx/nginx.conf
# 暴露80端口
EXPOSE 80 nginx配置:
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
underscores_in_headers on;
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
location /xxx/xxx {
proxy_pass http://service-xxx:8093/xxx/xxx;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Frame-Options;
add_header X-Frame-Options ALLOWALL;
}
location /xxx {
proxy_pass http://service-xxx:8080/xxx;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Frame-Options;
add_header X-Frame-Options ALLOWALL;
}
location /xxxxxxxx {
root /usr/share/nginx/html/;
}
}
}
旧的httpd作为基础镜像打包
FROM httpd:2.4.61
LABEL maintainer="lalala"
# 设置时区为上海东八区
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" >/etc/timezone
# 将编译生成的dist下的文件复制到容器/usr/local/apache2/htdocs中
COPY dist/ /usr/local/apache2/htdocs/myproject-vue/
# 暴露httpd的80端口
EXPOSE 80
正文到此结束
- 本文标签: 其他
- 本文链接: http://119.91.109.247:8443//article/74
- 版权声明: 本文由张亚东原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权