resolver 8.8.8.8; #必须配置!!!不然无法代理 server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { #default_type text/html; #正则截取域名前缀,例如www.xxx.com截取只要www if ( $host ~* (.*).(.*). ) { set $domain $1; } set $url https://$domain.xxx.com$request_uri; proxy_pass $url; #return 200 $domain; #return 200 $url; } }
复制使用nginx代码最好命令 nginx -t 检查一次。报错的话就自己手动输入,不然会有一些乱码问题;