dockerNginx代理本地目录
dockerNginx代理本地目录
ssl_certificate cert/5900588_test.zk.limengkai.work.pem;
ssl_certificate_key cert/5900588_test.zk.limengkai.work.key;
docker run -tdi --rm -v /containers/nginx:/etc/nginx -v /amydata:/amydata -v /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime -p 443:443 -p 80:80 --name nginx1 nginx
docker 代理本地目录
1.选择要挂载的目录
博主选择/amydata目录对外暴露
2.配置nginx文件
保存在宿主机 /a_nginx_conf/nginx.conf 修改 38 行,你要进行暴露的文件夹
location / {
#代理本地文件夹
root /amydata;
autoindex on;
}
mkdir -p /a_nginx_conf
mkdir -p /amydata
完整的 /a_nginx_conf/nginx.conf
worker_processes 4;
events {
worker_connections 1024;
}
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
http {
include mime.types;
default_type application/octet-stream;
# 防止中文乱码
charset utf-8;
# 默认为on,显示出文件的确切大小,单位是bytes。
# 改为off后,显示出文件的大概大小,单位是kB或者MB或者GB
autoindex_exact_size off;
# 默认为off,显示的文件时间为GMT时间。
# 注意:改为on后,显示的文件时间为文件的服务器时间
autoindex_localtime on;
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;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
#配置跨域
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
location / {
#代理本地文件夹
root /amydata;
autoindex on;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
启动挂在容器,开启文件服务
对外暴露 服务器的 50000 端口 到 nginx 内
docker run -tdi --rm -v /a_nginx_conf/nginx.conf:/etc/nginx/nginx.conf -v /amydata:/amydata -v /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime -p 50000:80 --name nginx1 nginx
docker run -tdi --restart=always -v /a_nginx_conf/nginx.conf:/etc/nginx/nginx.conf -v /amydata:/amydata -v /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime -p 50000:80 --name nginx1 nginx
访问 即可 http://(域名)|(ip):50000
/amydata
nginx 配置文件
find / -name "*nginx.conf*"
find: '/proc/1/map_files': Operation not permitted
find: '/proc/6/map_files': Operation not permitted
find: '/proc/11/map_files': Operation not permitted
/etc/nginx/nginx.conf
原有配置文件
root@88bd90de686b:/# cat < /etc/nginx/nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
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;
}
修改的配置文件
保存在宿主机 /a_nginx_conf/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
http {
include 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;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
#配置跨域
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
location / {
#代理本地文件夹
root /amydata;
autoindex on;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
命令记录
docker stop nginx1 && docker rm nginx1
docker run -tdi --name nginx1 nginx /bin/bash
dockerNginx代理本地目录的更多相关文章
- hdfs 通过NFSV3 加载至本地目录
常常会有这种需求,把HDFS的目录MOUNT到本地目录,然后方便使用LINUX下面的命令直接操作. FUSE也可以达到同样的效果,但是配置比较复杂,新的HADOOP版本都建议使用NFS3来完成这个需求 ...
- 使用 lsyncd 本地目录实时备份
转自 https://segmentfault.com/a/1190000002737213 2.1安装lsyncd # rpm -ivh http://dl.fedoraproject.org/pu ...
- 用java 代码下载Samba服务器上的文件到本地目录以及上传本地文件到Samba服务器
引入: 在我们昨天架设好了Samba服务器上并且创建了一个 Samba 账户后,我们就迫不及待的想用JAVA去操作Samba服务器了,我们找到了一个框架叫 jcifs,可以高效的完成我们工作. 实践: ...
- Nginx反向代理的目录访问问题
Nginx反向代理的目录访问问题 2013-05-13 23:21 2730人阅读 评论(0) 收藏 举报 从昨天就开始纠结了,在做实验的时候,遇到目录访问的问题,如下 前端nginx vhost的设 ...
- 根据字符串创建FTP本地目录 并按照日期建立子目录返回路径
/** * 根据字符串创建FTP本地目录 并按照日期建立子目录返回 * @param path * @return */ private String getFolder(String path) { ...
- java+js实现完整的图片展示本地目录demo
java+js实现完整的图片展示本地目录demo 最近的项目满足需要,实现通过一个前端button点击事件,流行音乐浏览下的全部图片: 思路: - 获取到所需展示图片的本地目录内全部图片的文件绝对路径 ...
- 递归删除本地目录和ftp目录
本地目录: void CAutoDelete::DoRecursionLocalDelete(CString& localDirectory) { CFileFind finder; CStr ...
- python打开一个本地目录文件路径
os.path.abspath()os 模块为 python 语言标准库中的 os 模块包含普遍的操作系统功能.主要用于操作本地目录文件.path.abspath()方法用于获取当前路径下的文件. 比 ...
- 将本地目录上传值git仓库
创建git仓库 以github为例,登录账号建立一个仓库,然后将仓库地址copy下来. 本地目录 初始化 $ git init 添加至版本库 $ git add -A 提交 $ git commit ...
随机推荐
- 【C++】实现D3D9 的 Inline hook
[C++]实现D3D9 的 Inline hook 简单介绍一下HOOK原理: 函数调用的过程大致是 先push 参数 进去,再执行 call 函数地址 ,进入函数.此时将所调用的函数的前五个字节 ...
- 04_Linux基础-.&..-cat-tac-重定向-EOF-Shell-more-ps-less-head-tail-sed-grep-which-whereis-PATH-bash-usr-locate-find
04_Linux基础-.&..-cat-tac->&>>-EOF-Shell-more-ps-less-head-tail-sed-grep-which-wherei ...
- eBackup备份服务器安装及配置
####### 原博客地址 创建虚拟机 选择第一个 分配硬盘 其余默认 导入压缩包安装eBackup备份软件 用户名root 密码Cloud12#$ 查看ip地址 连接xftp导入包 安装备份软件 # ...
- GB/T 28181联网系统通信协议结构和技术实现
技术回顾 在本文开头,我们先一起回顾下GB/T28181联网系统通信协议结构: 联网系统在进行视音频传输及控制时应建立两个传输通道:会话通道和媒体流通道. 会话通道用于在设备之间建立会话并传输系统控制 ...
- 【设计模式】Java设计模式 - 单例模式
[设计模式]Java设计模式 - 单例模式 不断学习才是王道 继续踏上学习之路,学之分享笔记 总有一天我也能像各位大佬一样 分享学习心得,欢迎指正,大家一起学习成长! 原创作品,更多关注我CSDN: ...
- KingbaseES集群部署工具安装
关键字: KingbaseES.Java.ClientTools 一.安装前准备 1.1 软件环境要求 金仓数据库管理系统KingbaseES V8.0支持微软Windows 7.Windows XP ...
- 写个续集,填坑来了!关于“Thread.sleep(0)这一行‘看似无用’的代码”里面留下的坑。
"我报名参加金石计划1期挑战--瓜分10万奖池,这是我的第2篇文章,点击查看活动详情" 你好呀,我是居家十三天只出了一次小区门的歪歪. 这篇文章是来填坑的,我以前写文章的时候也会去 ...
- 我的Go并发之旅、01 并发哲学与并发原语
注:本文所有函数名为中文名,并不符合代码规范,仅供读者理解参考. 上下文 上下文(Context)代表了程序(也可以是进程,操作系统,机器)运行时的环境和状态,联系程序整个生命周期与资源调用,是程序可 ...
- 详解字符编码与 Unicode
人类交流使用 A.B.C.中 等字符,但计算机只认识 0 和 1.因此,就需要将人类的字符,转换成计算机认识的二进制编码.这个过程就是字符编码. ASCII 最简单.常用的字符编码就是 ASCII(A ...
- 了解如何配置Nginx日志
设置access_log 访问日志主要记录客户端的请求.客户端向Nginx服务器发起的每一次请求都记录在这里.客户端IP,浏览器信息,referer,请求处理时间,请求URL等都可以在访问日志中得到. ...