V
V
Vadim2014-11-26 14:39:54
Nginx
Vadim, 2014-11-26 14:39:54

How to set up nginx in Plesk for a specific domain?

Given - hosting with a Plesk 11.5 panel, apache and nginx are running on the server as a frontend server. By default, nginx redirects requests to Apache by default.
But there was a need to change the nginx settings on one specific domain so that requests would not go to Apache, but to another service. How to register this in the config file is not a question, everything is clear here. The question is how to make this config file picked up by nginx. In Splash, config files are automatically generated for any changes, so making the necessary entries there is not an option. Refuse Splash - this scenario is also not considered. The support poked around and lowered his hands. Smoking manuals did not give any result.
The last hope is the collective mind. Is there really no way in such a situation to add your own settings for nginx for a specific domain to the auto-generated config files?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vadim, 2014-11-27
@vshemarov

In general, suddenly someone will come in handy: it is possible, but with certain restrictions.
1. First, the required domain is created through Plesk.
2. The required config is written to /var/www/vhosts/system/[domain_name]/conf/vhost_nginx.conf.
3. Domain configs are rebuilt by calling the command line:
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain [domain_name]
And in the future, if there is a vhost_nginx.conf file, it will be included in the domain config.
Now about the limitations:
1. The vhost_nginx.conf file is included inside the server { ... } section, at its very end, which imposes its own limitations. For example, adding your own location / { ... } section will not work, because it's already there (Plesk carefully inserted it), but location = / { ... } - you can.
2. By default, the same vhost_nginx.conf file is included for both https and http, in some cases this may be important.
In principle, you can completely control the creation and regeneration of all configs (for both nginx and apache), but for this you need to edit the scripts that do this (the system allows the use of custom scripts for these purposes). Read more here:
download1.parallels.com/Plesk/PP11/11.5/Doc/en-US/...
I hope this information will save someone time and nerves.

P
Puma Thailand, 2014-11-26
@opium

nginx does an include, add the config for the desired domain to it

G
germani, 2015-02-21
@germani

My solution to this situation - maybe someone else can save half a day =)
infa was originally taken here
what I did;
1 mkdir /usr/local/psa/admin/conf/templates/custom/domain
2 cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf /templates/custom/domain/
3 create a conf folder in it our http and https
configurations nginx.ssl.conf - connects first
nginx.conf
4 edit the new nginxDomainVirtualHost.php
and so the cut from nginxDomainVirtualHost.php
will be like this

<?php $file = $VAR->domain->physicalHosting->vhostDir . '/conf/nginx.' . ($OPT['ssl'] ? 'ssl.' : '') . 'conf'; ?>
<?php $file_exists = file_exists( $file ); ?>

<?php if ( !$file_exists ){ ?>
server {

and at the very end after
it will be like this
}
<?php } else { ?>

include <?php echo $file; ?>;

<?php } ?>

and then we can do our own server configuration, I did to redirect the websocket,
if anything can and should be corrected, write.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question