Answer the question
In order to leave comments, you need to log in
How to add multiple websites to one port in nginx?
Good afternoon. there is a home server on nginx ports 80 and 443 are open. it has a website mywebsite.com i
want to add a new website on the same port nothing works.
create config in /etc/nginx/sites-available/mysecondwebsite.com
and sim link ln -s mysecondwebsite.com ../sites-enabled/mysecondwebsite.com
server {
listen 80;
listen [::]:80 ipv6only=on;
root /var/www/mysecondwebsite.com;
index index.html;
server_name mysecondwebsite.com;
location / {
try_files $uri/ /index.html?$args;
}
}
Answer the question
In order to leave comments, you need to log in
The config looks correct, you need to make sure that it is loaded, look at the access / error logs.
I usually do symlinks a little differently:
It is very useful to make separate access.log for each virtual server
How can I check if the host is loaded or not? log files were created but there is nothing in them
as I see it, there are two options for solving the problem, maybe I'm wrong ...
if there is an opportunity, for example, you can do this
server {
listen 80;
server_name domain.com;
location /mywebsite {
.......
}
location /mysecondwebsite {
.......
}
}
or create two config files
mywebsite.conf and mysecondwebsite.conf and
write
server {
listen 80;
server_name mywebsite.com;
}
server {
listen 80;
server_name mysecondwebsite.com;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question