Answer the question
In order to leave comments, you need to log in
How to properly set up virtual hosts on nginx?
The task is as follows: you need to configure several services on the local computer (of the "server" type). And they must be on different domains.
The web server is nginx. On my computer I wrote the following in /etc/hosts:
192.168.2.123 cinnamon
192.168.2.123 gitlab
192.168.2.123 redmine
server {
listen 80;
server_name cinnamon www.cinnamon;
server_tokens off;
root /home/webservers/public_html/default;
access_log /var/log/nginx/default_access.log;
error_log /var/log/nginx/default_error.log;
location / {
try_files $uri $uri/index.html $uri.html;
}
}
server {
listen 80;
server_name gitlab www.gitlab;
server_tokens off;
root /home/webservers/public_html/default1;
access_log /var/log/nginx/default_access.log;
error_log /var/log/nginx/default_error.log;
location / {
try_files $uri $uri/index.html $uri.html;
}
}
Answer the question
In order to leave comments, you need to log in
Maybe because both have the same root?root /home/webservers/public_html/default;
Try to do nginx -t and make sure that the config contains no errors and that nginx actually applied it. What is your distribution? Are the config sections in the same file?
Make access_log and error_log on different sites into different files, and not into the same one, and look in the logs to which site the calls are made.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question