• The APS Catalog has been deprecated and removed from all Plesk Obsidian versions.
    Applications already installed from the APS Catalog will continue working. However, Plesk will no longer provide support for APS applications.
  • Please be aware: with the Plesk Obsidian 18.0.78 release, the support for the ngx_pagespeed.so module will be deprecated and removed from the sw-nginx package.

Question How to overwrite existing nginxs configurations?

L. Hagen

Basic Pleskian
Server operating system version
Ubuntu 22.04
Plesk version and microupdate number
Obsidian v18
Hi,

I'm trying to setup my private docker registry with the public port 5000 on my server running Plesk. In the internet I found several tutorials. They all need to extend the nginx configuration line this:
server {
listen 80;
server_name SERVER_URL;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

location / {
if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go ).*$" ) {
return 404;
}

proxy_pass http://localhost:5000;
proxy_set_header Host $http_host; # required for docker client's sake
proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 900;
}
}

So far so good. I stepped now into the Additional nginx directives and tried to extend it like this:
location / {
if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go ).*$" ) {
return 404;
}

proxy_pass http://localhost:5000;
proxy_set_header Host $http_host; # required for docker client's sake
proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 900;
}

But I get always an error
Invalid nginx configuration: nginx: [emerg] duplicate location "/" in /var/www/vhosts/system/SERVER_URL/conf/vhost_nginx.conf:1 nginx: configuration file /etc/nginx/nginx.conf test failed

The nginx code itself seems to be ok, but what can I do to get to to work? And on a standalone system without Plesk it works too. So I expect that it has any conflicts with the Plesk configuration, but of course I don't want to hard-code any changes into configuration files outside the Plesk UI.

I appreciate any help.

Thx and best regards,
Lars
 
Invalid nginx configuration: nginx: [emerg] duplicate location "/" in /var/www/vhosts/system/SERVER_URL/conf/vhost_nginx.conf:1 nginx: configuration file /etc/nginx/nginx.conf test failed

This usually happens when nginx Proxy mode is still enabled for a domain. Disable proxy mode and click the Apply button first and then add the additional nginx directives.
 
Back
Top