A
A
Axwellweb2019-04-25 16:26:31
Network administration
Axwellweb, 2019-04-25 16:26:31

How to make Apache2 return ServerName correctly?

Good afternoon, connoisseurs!
The problem is the following, there are 2 sites on the VPS, site1.ru and site2.ru
site1.ru - on https, site2.ru - no.
apache2 settings for websites:

<VirtualHost localhost:81>
  ServerName site1.ru
  ServerAlias www.site1.ru mirror.site1.ru
  ServerAdmin ****@gmail.com
  DocumentRoot /var/www/site1.ru
  <Directory "/var/www/site1.ru">
    AllowOverride All
    Options +Includes
  </Directory>
</VirtualHost>
<VirtualHost localhost:81>
  ServerName site2.ru
  ServerAlias www.site2.ru
  ServerAdmin ****@gmail.com
  DocumentRoot /var/www/site2.ru
  <Directory "/var/www/site2.ru">
    AllowOverride All
    Options +Includes
  </Directory>
</VirtualHost>

Listening on port 81 because nginx...
server {
  listen 80;
  root /var/www/site1.ru;
  server_name site1.ru www.site1.ru;
  index index.php index.html;
  location ~* ^(?!/img/|/upload/map/).+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|js)$ {
    access_log off;
    expires 30d;			
  }
  location / {
    proxy_pass   http://localhost:81;
  }
  location ~ /\.ht {
    deny  all;
  }
}

for site2.ru the settings are the same.
But here's the problem, site2.ru opens site1, and www.site2.ru opens site2
How to fight? Maybe apache2 is configured incorrectly? Or is it nginx?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Axwellweb, 2019-04-26
@Axwellweb

The problem was solved by itself, the settings turned out to be correct!
Apparently DNS records were updated longer than usual...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question