Created
March 14, 2022 09:32
-
-
Save Rndwiga/e1335597f948ae14352a35137b635f6e to your computer and use it in GitHub Desktop.
NGINX Virtual file for dynamic subdomain routing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
server_name tyondo.lan; | |
root /var/www/apps/tyondo/public; | |
index index.php index.html; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/run/php/php8.1-fpm.sock; | |
} | |
} | |
server { | |
server_name ~^(?<account>.+)\.tyondo\.lan$; | |
if ( !-d /var/www/apps/$account){ | |
return 404; | |
} | |
root /var/www/apps/$account/public; | |
index index.php index.html | |
access_log /var/log/nginx/$account-access.log; | |
error_log /var/log/nginx/$account-error.log; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; | |
# fastcgi_param ACCOUNT $account; # $_SERVER['ACCOUNT'] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment