Nginx is able to run several servers. So far I've put 2 WordPress sites on the same server and they run well over LAN. Something like 192.168.1.5:80 and 192.168.1.5:81. On a router level external port 80 is forwarded to both: 80 and 81 of the same server.
The problem is domains - how to feed to Nginx that on request http://www.domain1.com it has to bring up website1, but on www.domain2. - website2 ???
On Synology devices that is done via Virtual Hosts. I found that on Nginx something similar is related to
etc/nginx/sites-available/openmediavault-nginx file. At least Nginx writes data of both websites into this file. Now the file of mine looks like this:
server {
listen [::]:80 ipv6only=off;
set $root_path "/media/d1fe4050-e804-4831-b6b5-e8903ffe2b53/web/website1/";
root $root_path;
index index.php;
set $socket "unix:/var/run/fpm-7f79544d-f5b0-45af-9f2c-3a6a4fb79ffe.sock";
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass $socket;
fastcgi_index index.php;
include fastcgi_params;
}
access_log /var/log/nginx/3204618d-bba5-487b-a595-e2ef8fedb39a-access.log;
error_log /var/log/nginx/3204618d-bba5-487b-a595-e2ef8fedb39a-error.log;
large_client_header_buffers 4 8k;
}
server {
listen [::]:81 ipv6only=off;
set $root_path "/media/d1fe4050-e804-4831-b6b5-e8903ffe2b53/web/website2/";
root $root_path;
index index.php;
set $socket "unix:/var/run/fpm-a65bc8cd-588c-4b74-82f9-648ae0ec6646.sock";
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass $socket;
fastcgi_index index.php;
include fastcgi_params;
}
access_log /var/log/nginx/85d8d84e-6c5f-43b4-b74e-2f8ff6435006-access.log;
error_log /var/log/nginx/85d8d84e-6c5f-43b4-b74e-2f8ff6435006-error.log;
large_client_header_buffers 4 8k;
}
Alles anzeigen
But right now Nginx brings up only first (the oldest) site on both domain requests. What should I do to have it working right?