Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx lens doesn't support recursive blocks #179

Closed
jeffNagra opened this issue Nov 25, 2014 · 3 comments
Closed

nginx lens doesn't support recursive blocks #179

jeffNagra opened this issue Nov 25, 2014 · 3 comments
Labels

Comments

@jeffNagra
Copy link

As discussed with Raphink....

The nginx lens is failing the parse even the default nginx.conf supplied with the nginx package (below)…

set /augeas/load/nginx/lens "Nginx.lns"
set /augeas/load/nginx/incl "/home/root/jeff"
load
print /augeas//error

/augeas/files/home/root/jeff/error = "parse_failed"
/augeas/files/home/root/jeff/error/pos = "410"
/augeas/files/home/root/jeff/error/line = "20"
/augeas/files/home/root/jeff/error/char = "0"
/augeas/files/home/root/jeff/error/lens = "/usr/share/augeas/lenses/dist/nginx.aug:61.10-.57:"
/augeas/files/home/root/jeff/error/message = "Iterated lens matched less than it should"

Full default nginx.conf (comes with the nginx RPM):

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    index   index.html index.htm;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        server_name  localhost;
        root         /usr/share/nginx/html;

        #charset koi8-r;

        #access_log  /var/log/nginx/host.access.log  main;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        # redirect server error pages to the static page /40x.html
        #
        error_page  404              /404.html;
        location = /40x.html {
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
        }
    }
}
@raphink raphink added the bug label Nov 25, 2014
@raphink
Copy link
Member

raphink commented Nov 25, 2014

The Nginx lens is not recursive (yet).

@craigloftus
Copy link

The letsencrypt project is using Augeas for apache support, and would like to use it for Nginx as well.

I copied lvm.aug to add support for recursion (04cb46d), but I am lost as to how to support the location block syntax. The syntax for lenses has me baffled.

lutter added a commit to lutter/augeas that referenced this issue Apr 9, 2015
The Nginx.lns is now recursive and can handle nested blocks.

It can now also deal with some special block-start directives like
'location' and 'if' which have additonal stuff between the keyword and the
opening brace.

The file tests/root/etc/nginx/nginx.conf if the stock Nginx configuration
example from their siurce control, with everything that was commented out
activated. Having that file makes sure (via tests/test-get.sh) that we
successfully parse that file.

Fixes hercules-team#179
@lutter
Copy link
Member

lutter commented Apr 9, 2015

@craigloftus could you have a look at PR #225 and let me know if (a) that updated lens covers everything you'd need and (b) if the tree it produces is reasonable for your pruposes, especially how 'if' and 'location' directives are parsed ?

lutter added a commit to lutter/augeas that referenced this issue Apr 9, 2015
The Nginx.lns is now recursive and can handle nested blocks.

It can now also deal with some special block-start directives like
'location' and 'if' which have additonal stuff between the keyword and the
opening brace.

The file tests/root/etc/nginx/nginx.conf if the stock Nginx configuration
example from their siurce control, with everything that was commented out
activated. Having that file makes sure (via tests/test-get.sh) that we
successfully parse that file.

Fixes hercules-team#179
lutter added a commit to lutter/augeas that referenced this issue Apr 10, 2015
The Nginx.lns is now recursive and can handle nested blocks.

It can now also deal with some special block-start directives like
'location' and 'if' which have additonal stuff between the keyword and the
opening brace.

The file tests/root/etc/nginx/nginx.conf if the stock Nginx configuration
example from their siurce control, with everything that was commented out
activated. Having that file makes sure (via tests/test-get.sh) that we
successfully parse that file.

Fixes hercules-team#179
@lutter lutter closed this as completed in 3e39c26 May 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants