来自Nginx中proxy_pass uri中主机名的正则表达式

前端之家收集整理的这篇文章主要介绍了来自Nginx中proxy_pass uri中主机名的正则表达式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我想做的事情如下:

  1. server_name ~^(www\.)?(?
最佳答案
未经测试,但请试一试:

  1. server_name ~^(www\.)?[^.]+.example.org$;
  2. if ($host ~* ^(www\.)?([^.]+).example.org$) {
  3. set $subdomain $2;
  4. }
  5. location / {
  6. proxy_pass http://example.org:8080/$subdomain;
  7. }

猜你在找的Nginx相关文章