1. docker 安装 nginx
docker run -d -p 80:80 \
-v /xl/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v /xl/nginx/index.html:/usr/share/nginx/html/index.html \
--name nginx nginx:latest
2. 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;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
server{
listen 80;
server_name 101.43.236.92;
location = / {
proxy_pass https://www.baidu.com;
}
location ~ /index {
root /usr/share/nginx/html;
index index.html;
}
}
}
3.参考文档
https://www.cnblogs.com/cativen/p/16641234.html