IP-based virtual hosts do not work properly when Nginx is enabled

Created:

2016-11-16 13:09:54 UTC

Modified:

2017-08-16 17:17:19 UTC

0

Was this article helpful?


Have more questions?

Submit a request

IP-based virtual hosts do not work properly when Nginx is enabled

Applicable to:

  • Plesk 11.x for Linux

Symptoms

When Nginx is enabled, IP-based virtual hosts (default domains on an IP) do not work properly if more than one IP has a default domain assigned.

A domain is shown instead of Plesk default server page .

Cause

When Nginx makes an IP-based proxy request, it connects to Apache on the address 127.0.0.1 and sends the request. This means that from Apache's point of view, all virtual hosts are on the same IP address – 127.0.0.1 – which causes IP-based virtual hosts to work improperly.

That is, the first virtual host defined in the /usr/local/psa/admin/conf/ip_vhosts_bootstrap.conf file becomes the default on all IP addresses, including those which do not have a default domain assigned.

This is a software issue with internal ID #PPPM-269 . The issue will be fixed in a future update for which a new Knowledgebase article will be created. You may subscribe to new articles on Plesk products if you wish to receive notifications about their creation.

Resolution

As a workaround, you may use following instructions.

  1. Go to the /usr/local/psa/admin/conf/templates directory:

    # cd /usr/local/psa/admin/conf/templates
  2. Create a sub-directory called custom .

    # mkdir custom
  3. Copy the /usr/local/psa/admin/conf/templates/default/nginx.php file to the custom directory:

    # cp default/nginx.php custom/
  4. Edit the nginx.php file by replacing 127.0.0.1 with $host or $server_addr

    # vi custom/nginx.php
  5. You should get the following as a result:

    proxy_pass http://$server_addr:<?php echo $VAR->server->webserver->httpPort ?>;
  6. Rebuild the web-server configuration:

    /usr/local/psa/admin/sbin/httpdmng --reconfigure-all
Have more questions? Submit a request
Please sign in to leave a comment.