0

Hello i am trying to configure an nginx web server to serve different frameworks from different subdomains. As well as serving a site on the main domain. For example

  • example.com - serves the main website
  • site1.wp.example.com - serves a wordpress website
  • site2.ci.example.com - serves a codeigniter website
  • site3.la.example.com - serves a laravel website

The problem i am having is this capture is capturing the example.com address:

server_name ~^(www\.)?(?<vhost>.+)\.wp\.example\.com$;

This is shown in the error logs

"/var/www//web" existence failed (2: No such file or directory) while logging request, 
client: xxx.xxx.xxx.xx, 
server: ~(www\.)?(?<vhost>.+)\.wp\.example\.com$, 
request: "GET / HTTP/2.0", 
upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock", 
host: "example.com"

I thought that .+ meant you had to match 1 or more ?

jwtea
  • 454
  • 5
  • 15
  • Dunno anything about nginx, but your regex matches only strings ending with `.wp.example.com`. Is the `.wp` in the beginning really intended? That will **only** match the *wordpress* site. – SamWhan Jun 27 '17 at 12:19
  • Is it also the default domain? There is always a default domain and unless you have defined one, the first server block will be used. – Richard Smith Jun 27 '17 at 12:45
  • Sorry i wasn't clear enough. This regex is capturing example.com somehow. I'm not a nginx wizard but i thought servername directives decided what server block is used. For example my example.com block has server_name example.com; – jwtea Jun 27 '17 at 13:26

0 Answers0