1、使用docker 下载最新nginx1.21.1
2、配置nginx.conf文件 配置反向代理
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
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;
upstream myServerSetting {
server www.baidu.com;
server www.taobao.com;
}
server {
listen 80;
server_name 192.168.31.133;
location / {
proxy_pass https://www.baidu.com;
# proxy_pass http://myServerSetting;
proxy_redirect default;
}
location ~ /myweb/ {
proxy_pass http://192.168.31.133:8081;
}
location ~ /mywebtwo/ {
proxy_pass http://192.168.31.133:8082;
}
}
}