详细代码如高:

#user nobody;
worker_processes 1;
 
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
 
#pid  logs/<a style='color:#f60; text-decoration:underline;' href="https://www.php.cn/zt/16000.html" target="_blank">nginx</a>.pid;
 
 
events {
 worker_connections 10两4;
}
 
 
http {
 include  mime.types;
 default_type application/octet-stream;
 
 #log_format main &#39;$remote_addr - $remote_user [$time_local] "$request" &#39;
 #     &#39;$status $body_bytes_sent "$http_referer" &#39;
 #     &#39;"$http_user_agent" "$http_x_forwarded_for"&#39;;
 
 #access_log logs/access.log main;
 
 sendfile  on;
 #tcp_nopush  on;
 
 #keepalive_timeout 0;
 keepalive_timeout 65;
 
 #gzip on;
 
 #设备容许领布形式为8m
 client_max_body_size 两0m;
 client_body_buffer_size 51两k;
 
 add_header access-control-allow-origin *; 
 add_header access-control-allow-headers x-requested-with; 
 add_header access-control-allow-methods get,post,options; 
 
 server { 
 listen  80; 
 server_name www.xxx.com; 
 location / { 
 proxy_pass http://1两7.0.0.1:8080; 
 proxy_set_header host $host; 
 proxy_set_header x-real-ip $remote_addr; 
 proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; 
 } 
 }
 
 server { 
 listen  80; 
 server_name www.aaa.com; 
 location / { 
 proxy_pass http://1两7.0.0.1:9989; 
 proxy_set_header host $host; 
 proxy_set_header x-real-ip $remote_addr; 
 proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; 
 } 
 }
 
 
 #泛域名解析
 server { 
 listen  80; 
 server_name *.web.yuyuyun.cn; 
 location / { 
 # 泛域名入手下手设施
 if ( $host ~* (.*)\.(.*)\.(.*)\.(.*) ) {
 set $domain $1; #猎取当前的 域名前缀
 }
 proxy_pass http://1两7.0.0.1:1119/$domain/; 
 proxy_set_header host $host; 
 proxy_set_header x-real-ip $remote_addr; 
 proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; 
 } 
 
 } 
 
}
登录后复造

以上即是Nginx假设设置域名重写以及泛域名解析的具体形式,更多请存眷萤水红IT仄台另外相闭文章!

点赞(45) 打赏

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部