Skip to content

Instantly share code, notes, and snippets.

@nzkozar
Last active June 8, 2020 10:59
Show Gist options
  • Save nzkozar/5390d8c7ab78bcb0609e9d58f97ae183 to your computer and use it in GitHub Desktop.
Save nzkozar/5390d8c7ab78bcb0609e9d58f97ae183 to your computer and use it in GitHub Desktop.
A server block configuration for nginx, splitting one domain name into two locations, by listening on different ports
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/A;
index index.html;
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
server {
listen 8191;
listen [::]:8191 default_server;
root /var/www/html/B;
index index.html;
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment