• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • 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 How can I make my changes to Nginx site config Permanent per site?

ShockWave

New Pleskian
Server operating system version
Centos 7.9
Plesk version and microupdate number
18.0.63
Hey guys,

Could not find posted question relatable.

I installed Varnish on the server manually.
The current plan is Nginx -> Varnish -> Httpd.

Initially, I got a redirect issue whenever I pointed nginx to varnish through the proxy_pass.
I contacted Liquid support and they solved this by turning of the Redirect from http to https in the Plesk admin. Not sure how safe this is.

My main problem now is that whenever I make changes to the nginx.conf in /var/www/vhosts/system/site1/conf/nginx.conf.
These are my changes under listen <ip> 443 location {}:
I can't figure out how to do it in plesk's Additional nginx directives for the site.
However, after 30 mins I believe the changes revert back to the original.
I do not want to set up these changes on every site.

So my question is, how do I make those changes permanently for selected sites?


Well without affecting ssl certificate renewal or anything.
Thanks for any response or advice.
 
Thanks much for the response.

I check the files on server.

It would seem the files I want to customize would be:
  • Bash:
    usr/local/psa/admin/conf/templates/default/server/nginxVhosts.php
That's where I saw the proxy pass configuration for nginx. I could be totally wrong.
Based on the configuration I see here: nginxDomainVirtualHost.php, doesn't seem like it would affect the proxy pass changes unless I'm wrong.
 
You don't necessarily need to create a custom template. I would avoid that because Plesk will update the templates and new features may not work.

Add the following in additional Nginx directives. The location will be matched before ``location /`` and will proxy_pass requests to the Varnish service:
Code:
location ~* /  {
    if ($scheme = http) {
        return 301 https://$host$request_uri;
    }
    proxy_set_header Ssl-Offloaded https;
    proxy_set_header Host $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_set_header X-Forwarded-Proto $scheme;
    proxy_pass http://127.0.0.1:6081;
}

Proxy mode needs to be enabled, in order to build the Apache configuration files. I would disable Smart static files processing and Serve static files directly by nginx in order to get all requests to Varnish.
 
Back
Top