创建配置文件
touch /nginx/ngin.conf
内容如下:
#user  nobody;
worker_processes  1;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;sendfile        on;underscores_in_headers on;   #该配置表示nginx可以转发带下划线的请求头(nginx默认是不转发带下划线的请求头)keepalive_timeout  65;server {listen       80;server_name  oversea;location / {proxy_pass https://192.168.56.103;}error_page   500 502 503 504  /json;location = /json {default_type application/json;add_header Content-Type 'text/html; charset=utf-8';return 500 '{"code": 500,"msg":"请求异常!"}';}}
}启动nginx
docker run -d --name nginx -p 80:80 -v /nginx/nginx.conf:/etc/nginx/nginx.conf nginx:1.23.3
配置文件注意事项
        underscores_in_headers on 
 该配置打开了下划线的自定义请求头可以被转发,默认nginx的转发是不会转发下划线的请求头
在nginx中,server_name指令用于指定虚拟主机的域名或IP地址。它可以用于匹配请求的主机头(HTTP请求头中的Host字段),从而确定哪个虚拟主机应该处理该请求。