What I have currently :

server {
    listen 80;
    server_name www.lala.com lala.com;
    location / {
        proxy_set_header Host $http_host;
        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;

I want to add (not replace) a new value to the server_name directive. What I tried to do using augtool:

augtool> set /files/etc/nginx/conf.d/site.conf/server[1]/*[self::directive="server_name"]/arg[last() + 1] "www.lala2.com lala2.com"
error: Failed to execute command
Setting /files/etc/nginx/conf.d/site.conf/server[1]/*[self::directive="server_name"]/arg[last() + 1] failed

Using :

augtool> print /augeas//error

Did not gave me any clue about the error. Could someone please help me with this ?


The server_name field is currently not parsed by Augeas, so it results in a single string, not an array.

As a result, you need to replace the whole thing.

  • 1
    Thank you, I'll save the current value using python-augeas, add the new one and replace the whole thing. – André Luís Lopes Sep 23 '20 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.