• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question Nginx - configure service on domain root

davorg

Basic Pleskian
I'm having trouble configuring a web service to run on the root of a domain on Plesk server.

I have a service running on port 2222.

I have the following in the "Additional nginx directives" section on the "Apache and nginx settings" page:

location / {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:2222/;
}

Just adding this seems to conflict with the main nginx config (and my service throws a 404 error). In order to get it working correctly, I need to comment out parts of the main config file

# location ~ /$ {
# index "index.html" "index.cgi" "index.pl" "index.php" "index.xhtml" "index.htm" "index.shtml";
#}


This works fine
until Plesk updates automatically and overwrites nginx.conf. At which point the site breaks again until I notice and comment the lines out again.

What's the approach I should be using to do this? Plesk must surely support having a domain that is completely powered by a web service?

Thanks,

Dave...
 
Don't create the domain in Plesk but create a complete config-file in /etc/nginx/conf.d/
Personally I don't think such a domain belongs in Plesk as it's not going to Apache.

If you still want to create the domain in Plesk you can..
You do have to start the name of the config-file with a letter lower than z to force it to be executed before zz010_psa_nginx.conf
That's the file that refers to all the Plesk websites.

If you're not hosting anything in Apache for that domain I would recommend turning off web-hosting in Plesk for that domain.
 
Last edited:
I have Apache Solr running on port 8983 of the domain root (i.e. http://domain:8983/solr/#/), and all I want nginx for is to reverse proxy so I can set up user authentication ONLY for the solr admin console. (I can't do basic authentication directly in the solr files because that then prevents the web applications that use it from accessing it.) From everything I've read online, the reverse proxy would be to localhost. Is this what the above is basically trying to do?
 
Just adding this seems to conflict with the main nginx config (and my service throws a 404 error). In order to get it working correctly, I need to comment out parts of the main config file

That's not necessarily true... try doing it in 3 steps
  1. Open "Apache & nginx settings", deselect "Proxy mode", click "OK"
  2. Open "Apache & nginx settings" again, put your "location /" config in "Additional nginx directives", click OK again
  3. Be happy!
 

I never did get around to this months ago... now looking into it again. So I need to go to the Plesk panel and somewhere add the following nginx directives?:

location ~ / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8983;
proxy_http_version 1.1;
proxy_pass_request_headers on;
proxy_store off;
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/.htpasswd;
}

Then obviously create the password. I didn't really understand the closing off of ports bit.
 
Back
Top