Answer the question
In order to leave comments, you need to log in
Set up 2 server blocks on different ports, but both of them go to one block?
First block
server {
listen 8003 default_server;
listen [::]:8003 default_server;
root /var/www/site1;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name my_ip;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
location = /404.html {
root /var/www/site1;
internal;
}
}
server {
listen 8002 default_server;
listen [::]:8002 default_server;
root /var/www/site2;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name my_ip;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
location = /404.html {
root /var/www/site2;
internal;
}
}
Answer the question
In order to leave comments, you need to log in
default_server
is used 1 time on the server and serves as /dev/null
for unparsed requests, and not everything in a row as you think.
It is needed in order to show you a picture of hello, you are on the server but something went wrong.
Especially when not a single site is yet tied to the server, but you need to show its performance.
In order not to embarrass the server, prescribe normal site names.
server {
listen 8002;
server_name site2.ru www.site2.ru ;
root /var/www/site2.ru
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question