• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question Additional nginx directives

andyxyz

Basic Pleskian
I want to add
proxy_set_header X-Forwarded-Proto: https;

(in order to make an application work with ssl / varnish without redirect loops.

When inserted manually like so

Code:
 #extension docker begin
        location ~ ^/.* {
                proxy_pass http://0.0.0.0:32780;
                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-Forwarded-Proto: https;
        }

        #extension docker end

        location / {
                proxy_pass http://78.129.161.190:7080;
                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-Forwarded-Proto: https;
                access_log off;
        }

everything works a treat.

Is there a way to add this to Additional nginx directives ? I know I could create a custom template but I want to apply this on a per domain basis not globally..
 
I think this cannot be added to the "additional directives" because of the nature of the location path. In a custom template however, you can still do this for a single domain only (or a set of domains), because these are PHP files. You could add a case switch (if ... then ... else accordingly) and create different parts of the template depending on the domain name that is being processed.
 
You can use a complete Nginx config file in /etc/nginx/conf.d folder.

I'm using it to have syncthing and ASSP on port 443 using virtual hosting. The daemon is running its plain http webserver on localhost (different port) or sometimes on another server with a self-signed certificate or plain http

I'm doing this all the time.
If the server_name is not defined in Plesk you should start the filename with zz090_

If it is also used in Plesk you will receive a warning that it's a duplicate, but that's not a problem. You should however start the filename with something lower (alphabetically) than zz010_plesk.conf as only the first one will be executed.

One thread of mine is a long monologue where I'm trying to make Plesk's letsencrypt work for a domain it is not actually handling.


The thread "Will this trick keep working?" in the thread "extensions"


I finally was able to solve the letsencrypt thing, but not to full satisfaction. I learned a lot on the process.
I will probably revisit that thread as a better solution would be to write my own letsencrypt provisioning for those domains (outside Plesk and therefore not reliant upon).
 
Last edited:
Back
Top