• Dear Pleskians! The Plesk Forum will be undergoing scheduled maintenance on Monday, 7th of July, at 9:00 AM UTC. The expected maintenance window is 2 hours.
    Thank you in advance for your patience and understanding on the matter.

Input How to use Multiple IP's for 1 Domain [IMPORTANT FEATURE THAT'S MISSING NATIVELY]

boostedhost

New Pleskian
Server operating system version
Ubuntu 20 & 22
Plesk version and microupdate number
18
Assigning two different IPs to one website is absolutely possible. Let me explain how, as it took me quite a bit of headache to figure this out.

Step 1:
Add the secondary IP to your Plesk server, but don't assign it to any websites. You don’t need to associate it directly with any domain.

Step 2:
FTP into your server and navigate to /opt/psa/admin/conf/templates/default/domain. Open the nginxDomainVirtualHost.php file.

In this file, you’ll see a lot of code, but don’t worry—you only need to add four lines. Here's what to add:

PHP:
server {
<?php if ($OPT['ssl'] && $OPT['http3']) : ?>
listen <?php echo $OPT['ipAddress']->escapedAddress . ':' . $OPT['frontendPort'] ?> quic;


--->listen YOUR SECOND IP:<?php echo $OPT['frontendPort'] ?> quic; <---


add_header Alt-Svc <?php echo '\'h3=":' . $OPT['frontendPort'] . '"; ma=86400\'' ?>;
<?php endif; ?>
listen <?php echo $OPT['ipAddress']->escapedAddress . ':' . $OPT['frontendPort'] . ($OPT['ssl'] ? ' ssl' : '') ?>;


---->listen YOUR-SECOND-IP:<?php echo $OPT['frontendPort'] . ($OPT['ssl'] ? ' ssl' : '') ?>; <---


<?php if ($OPT['ssl'] && $OPT['http2']) : ?>
http2 on;
<?php endif; ?>

Further down in the file, you’ll find another similar block. Update it as well:

PHP:
server {
<?php if ($OPT['ssl'] && $OPT['http3']) : ?>
listen <?php echo $OPT['ipAddress']->escapedAddress . ':' . $OPT['frontendPort'] . ' quic' . ($OPT['default'] ?  ' reuseport' : '') ?>;

--->listen YOUR-SECOND-IP:<?php echo $OPT['frontendPort'] ?> quic; <------

add_header Alt-Svc <?php echo '\'h3=":' . $OPT['frontendPort'] . '"; ma=86400\'' ?>;
<?php endif; ?>
listen <?php echo $OPT['ipAddress']->escapedAddress . ':' . $OPT['frontendPort'] .
($OPT['default'] ? ' default_server' : '') . ($OPT['ssl'] ? ' ssl' : '') ?>;

---->listen YOUR-SECOND-IP:<?php echo $OPT['frontendPort'] . ($OPT['ssl'] ? ' ssl' : '') ?>; <----

<?php if ($OPT['ssl'] && $OPT['http2']) : ?>
http2 on;
<?php endif; ?>

Make sure to remove the --> and <-- markers, and replace "YOUR-SECOND-IP" with the actual IP you’re adding.

Final Step:
Restart NGINX with
Code:
systemctl restart nginx
and regenerate all domain configurations on your Plesk server by running the following command via SSH:
Code:
plesk repair web -y
 
Please do not edit the default templates directly because they WILL get overwritten. Instead, the best way to edit it would be to to make a copy of the template you want to edit (nginxDomainVirtualHost.php in this case) to /usr/local/psa/admin/conf/templates/custom (so in your case, you'll want to copy /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php to /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php)

You can refer to Changing Virtual Hosts Settings Using Configuration Templates for how to properly edit the templates to further customize it to your needs.
 
Back
Top