赞
踩
docker pull nginx
2.获取nginx配置文件:
docker run --rm -v $PWD/nginx/conf.d/:/root/ nginx cp /etc/nginx/conf.d/default.conf /root/default.conf
3.修改nginx配置文件:
vim nginx/conf.d/default.conf
修改location /{}:
- location / {
- #root /usr/share/nginx/html;
- #index index.html index.htm;
- #防止出现404错误
- proxy_set_header Host 代理地址;
- #proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- #防止出现426错误
- proxy_http_version 1.1;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "Upgrade";
- #代理地址
- proxy_pass http://代理地址/;
-
- }
4.启动nginx:
docker run -v $PWD/nginx/conf.d/:/etc/nginx/conf.d -p 8080:80 -d nginx
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。