Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. server_name *.hostname.com;
  2.  
  3. if ($host ~* ^([0-9]+).hostname.com$) {
  4. set $proxyhost 192.168.56.$1;
  5. }
  6.  
  7. proxy_pass http://$proxyhost;
  8.  
  9. server_name ~^(?<subnum>[0-9]+).hostname.com$;
  10.  
  11. proxy_pass http://192.168.56.$subnum;
  12.  
  13. map $host $backend {
  14.  
  15. default 1;
  16. ~*^(?P<number>[0-9]+).hostname.com$ $number;
  17.  
  18. # FIXME: [0-9]+ must be replaced to regex with accurate check 1..254 range
  19. # for example [1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-4] or similar
  20.  
  21. }
  22.  
  23. server {
  24. server_name *.hostname.com;
  25.  
  26. location / {
  27. proxy_pass http://192.168.56.$backend:80;
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement