nginx被configuration为apache(2.4.18)的反向代理和多个域的节点。
/etc/nginx/sites-available/example.com :
server { listen 80; server_name example.com; # /api is running on php/apache location /api { proxy_pass http://localhost:8080/api; proxy_set_header Host $host; } # all the rest is handled by node.js location / { proxy_pass http://localhost:3000; proxy_set_header Host $host; } }
/etc/apache2/sites-available/example.com :
<VirtualHost *:8080> ServerName example.com DocumentRoot /var/www/example.com/api </VirtualHost>
/etc/apache2/sites-available/000-default.conf :
<VirtualHost *:8080> # ServerName example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html </VirtualHost>
我还从/etc/apache2/sites-enabled/example.com添加了一个指向/etc/apache2/sites-available/example.com的符号链接。
一切都很好,除了/etc/apache2/sites-available/example.com不起作用。 它仍然使用/etc/apache2/sites-available/000-default.conf 。
我能做些什么来解决这个问题?
你有两个同名的虚拟主机<VirtualHost *:8080> 。 文件/etc/apache2/sites-available/000-default.conf第一个由Apache读取的文件,/etc/apache2/sites-available/example.com是第二个,所以Apache只加载第一个文件,它覆盖了所有其他的VirtulHosts文件。 为了防止出现这种问题,您应该删除/etc/apache2/sites-available/000-default.conf或将/etc/apache2/sites-available/000-default.conf内容更改为
<VirtualHost example.com:8080> ServerName example.com DocumentRoot /var/www/example.com/api </VirtualHost>