1. 基于Docker安装Nginx
1.创建挂载目录
mkdir -p /data/nginx/conf
2.准备需要挂载的nginx.conf文件
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream backServer{
server 1.117.150.239:81;
}
server {
listen 80;
server_name www.honeyyxk.com;
location / {
proxy_pass http://backServer/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
3.上传文件至先前创建好的目录下 4.拉取nginx镜像并运行
docker run --name nginx -d -p 80:80 -v /data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /data/nginx/logs:/var/log/nginx -d docker.io/nginx
2. 域名DNS解析
3. 检查本地hosts文件
4. 测试代理结果
如果能成功访问,则说明已经代理成功!
要想成为强者,决不能绕过挡道的荆棘,也不能回避风雨的冲刷。
|