• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Nginx subdomain vhost [SOLVED]

Praveen

New Pleskian
Hello
I am having trouble setting up the following configuration.

domain.com - nginx (reverse proxy) -> Apache ---- This works, no issues
myapp.domain.com - nginx (reverse proxy) -> Nodejs ---- This setup doesn't work.

Here are the things which I tried.

My app works as subfolder (by adding "location /myapp" and proxy directives in Plesk web server settings -> nginx directives )
domain.com/myapp - nginx (reverse proxy) -> Nodejs --- works

But I want it at the subdomain root level. So I created a subdomain in plesk and I tried the "location /" in nginx directive, but I am getting duplicate location.

So I deleted the subdomain and tried the server directive in /etc/nginx/conf.d/myapp.conf as follows,
Code:
server {
        listen 0.0.0.0:80;
        server_name myapp.domain.com;
        access_log /var/log/nginx/myapp.log;
        location / {
            proxy_pass http://127.0.0.1:38600/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-NginX-Proxy true;
            proxy_cache_bypass $http_upgrade;
        }
}
What I am getting is plesk default web page and not my app page. My subdomain DNS is also setup to point to main domain's ip address.

So how do I achieve this setup? Please help.
 
Hi Praveen,

without any specific root - folder definition, you always will be rooted to for example "/var/www/vhosts/default/htdocs". Please have a look at your default site - configuration, defined at "/etc/nginx/sites-enabled/*" to learn how your system is configured.
 
Thanks for the feedback. My nginx installation does not contain sites-enabled folder but it contains conf.d, so I added my subdomain conf in that folder as shown in the original post. Moreover is the root definition required? Because nginx has to just proxy the request (on a subdomain) to nodejs running on specific port in localhost.

I also tested with root set to my nodejs app folder but still getting the default domain page.
 
Last edited:
I got it to work. This line was causing the problem

access_log /var/log/nginx/myapp.log;

I missed double quotes for the path. o_O
 
Again the problem started showing up. I don't know what is causing the issue. Double quotes/no quotes does not make any difference.
 
Hi Praveen,

apache and nginx have both "configuration checker" included. Before you restart apache and/or nginx ( because you probably added configuration directives or modifications ), please always use the commands:

/usr/sbin/apachectl -t
Successfull configuration checks end with "Syntax OK"

or/and

/etc/init.d/nginx configtest
Successfull configuration checks end with:
Code:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

... to check your configuration(s). If you experience issues, please correct the mentioned parts from the output, or post your results here in the forums, so that people are able to help you with your investiations and possible solutions.


If you experience further issues, please include corresponding log - files and all possible configuration - files, so that people willing to help don't have to guess, when they try to help you.




Please have as well a look at:

... which already points to several solutions and ways, how you may find work-arounds for common issues. In addition, you will find usefull links, so that investigations are easier for you.
 
Back
Top