网站首页 > 博客文章 正文
1. 准备nginx.conf
server {
listen 80;
charset utf-8;
root /opt/static; # 注意此路径,即为docker run时的-v挂载中镜像路径
location / {
autoindex on; # 开启文件索引
autoindex_exact_size on; # 显示文件大小
autoindex_localtime on; # 显示文件时间
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
2. 编写Dockerfile
FROM nginx:stable-alpine
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d
CMD ["nginx", "-g", "daemon off;"]
3. 构建镜像
docker build -t nginx-static:1.0 .
4. 启动镜像
将向外导出的静态文件放在/opt/static123目录下即可,或者自己指定目录,通过启动docker时,-v指定。
注意: 其中-v /opt/static123:/opt/static 中的 /opt/static 路径为nginx.conf的 root路径
sudo docker run -e TZ=Asia/Shanghai -d --restart=always \
-p 9999:80 \
--name static_nginx \
-v /opt/static123:/opt/static \
--log-opt max-size=10m \
--log-opt max-file=1 \
nginx-static:1.0
5. 外部下载
wget http://ip:9999/xxx.rar
后台下载:wget -b http://ip:9999/xxx.rar
6. 403问题
针对:nginx "403 Forbidden"
文件权限不够
chmod 777 /opt
猜你喜欢
- 2024-10-05 Nginx + FastCGI 程序(C/C++) 搭建高性能web service
- 2024-10-05 使用nginx将服务器升级为https(nginx代理服务器配置)
- 2024-10-05 vue项目打包后部署到nginx(vue打包 nginx)
- 2024-10-05 Nginx Windows详细安装部署教程(nginx安装及配置教程)
- 2024-10-05 Vue实战091:Vue项目部署到nginx服务器
- 2024-10-05 Zabbix4.0企业级搭建实战(1)LNMP之Nginx服务器编译安装
- 2024-10-05 Linux上安装Nginx服务器(linux安装nginx详细步骤)
- 2024-10-05 Nginx 整合 FastDFS 实现文件服务器
- 2024-10-05 Linux中如何简单快速安装nginx以及如何配置
- 2024-10-05 在CentOS上安装nginx服务器(centos7离线安装nginx)
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- ifneq (61)
- 字符串长度在线 (61)
- googlecloud (64)
- messagesource (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)