routing - Run NGINX with subdomains -


i want run nginx 2 different subdomains , let them point different roots. therefore split 2 server blocks files, named them accordingly , set down below. when disable 1 of them both subdomains point same root working themselves, division between sub1 , sub2 not working. uses file finds first both subdomains.

sub1.example.de

server {         server_name sub1.example.de;         root /var/www/wordpress/;         index index.html index.htm index.php;         access_log /var/log/nginx/access.log;         error_log /var/log/nginx/error.log;           location ~\.php$ {                 try_files $uri =404;                    fastcgi_split_path_info ^(.+\.php)(/.+)$;                 fastcgi_cache_key $scheme$host$request_uri$request_method;                 fastcgi_cache_valid 200 301 302 30s;                 fastcgi_cache_use_stale updating error timeout invalid_header http_500;                 fastcgi_pass_header set-cookie;                 fastcgi_pass_header cookie;                 fastcgi_ignore_headers cache-control expires set-cookie;                  fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;                  fastcgi_index index.php;                 include fastcgi_params;                 fastcgi_param script_filename $document_root$fastcgi_script_name;                 #fastcgi_param script_filename $request_filename;                 fastcgi_param request_uri $request_uri;         }          location / {                 try_files $uri $uri/ /index.php;         }          location /wordpress/ {                 try_files $uri $uri/ /wordpress/index.php;         } } 

sub2.example.de

server {         server_name sub2.example.de;         root /var/www/phpmyadmin/;         index index.html index.htm index.php;          access_log /var/log/nginx/access.log;         error_log /var/log/nginx/error.log;           location ~\.php$ {                 try_files $uri =404;                 fastcgi_split_path_info ^(.+\.php)(/.+)$;                 fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;                  fastcgi_index index.php;                 include fastcgi_params;                 fastcgi_param script_filename $document_root$fastcgi_script_name;                 fastcgi_param request_uri $request_uri;         }          location / {                 try_files $uri $uri/ /index.php;         }   } 

my nginx.conf looks this:

worker_processes 1;  pid /var/run/nginx.pid;  events {         worker_connections 1024 ;  }  http {          ##         # basic settings         ##          sendfile on;         tcp_nopush on;         tcp_nodelay on;         keepalive_timeout 65;         types_hash_max_size 2048;         server_tokens off;          include /etc/nginx/mime.types;         default_type application/octet-stream;          ##         # logging settings         ##          access_log /var/log/nginx/access.log;         error_log /var/log/nginx/error.log;          ##         # gzip settings         ##          gzip on;         gzip_disable "msie6";         map $scheme $server_https {                 default off;                 https on;         }          ##         # virtual host configs         ##          include /etc/nginx/conf.d/*.conf;         include /etc/nginx/sites-enabled/*; } 


Comments