Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using an Ubuntu web server with Plesk 11.5.x. I've added Nodejs and now i want to adress the Nodejs app with a subdomain.

Website: domain.tld

Nodejs App: app.domain.tld

Currently working: domain.tld:2368, but i want to hide the port with the help of a subdomain.

I should be able to do the following:

upstream app_myApp {

server {
    server_name app.domain.tld;

    location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;

      proxy_pass http://app_myApp/;
      proxy_redirect off;

My problem is where to place this, because i am using Plesk. In Plesk 11.5's .../system/domain.tld/conf/vhost_nginx.conf are upstream and server commands not allowed. And location / isn't possible either.

I guess I would need something like /etc/nginx/sites-available/domain.tld. I have no idea where to add this without breaking plesk or my config being overwritten on an automatic plesk reconfig.

Any ideas?

share|improve this question

closed as off-topic by HopelessN00b Feb 26 '15 at 7:55

  • This question does not appear to be about server, networking, or related infrastructure administration within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 1 down vote accepted

You can edit nginx template file

mkdir /usr/local/psa/admin/conf/templates/custom/domain
cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain 

in new file /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php find following lines:

    location / {
<?php echo $VAR->includeTemplate('domain/service/proxy.php', $OPT); ?>

and adjust it to Your needs:

    location / {
<?php if ('mydomain.tld' == $VAR->domain->asciiName ) {
         echo $VAR->includeTemplate('PATHTONODECONFIG.php', $OPT); ?>
       } else {
         echo $VAR->includeTemplate('domain/service/proxy.php', $OPT); ?>

I suggest to parametrise this condition, to be more flexible

share|improve this answer
does a plesk update overwrite the nginxDomainVirtualHost.php file? – Florian Brinker Sep 25 '13 at 13:19
yes, you are right. it wil override these changes with new version. you should put custom template in this folder /usr/local/psa/admin/conf/templates/custom/domain/ i will fix manual too – sergres Sep 27 '13 at 6:14
thank you - does nginx use automatically the custom template afterwards? what would i have to put in the nodeconfig file. i assume sth like "proxy_pass mydomain.tld:2368;"; or "proxy_pass;"; in my case - but that didn't work – Florian Brinker Sep 30 '13 at 17:43
Worked now with proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass; proxy_redirect off; – Florian Brinker Oct 9 '13 at 9:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.