gixy icon indicating copy to clipboard operation
gixy copied to clipboard

[nginx_parser] ERROR

Open ludovicsclain opened this issue 3 years ago • 5 comments

Hi 👋  Gixy just installed and tested and I have a NGINX-PARSER error on all my .conf file: [nginx_parser] ERROR Failed to parse config "/etc/nginx/nginx.conf": char 272 (line:3, col:1)

[nginx_parser] ERROR Failed to parse config "/etc/nginx/sites-available/my-website.conf": char 269 (line:4, col:1)

So are the results reliables (I have no issue)? Thanks for your help 🙏 

ludovicsclain avatar Dec 14 '21 06:12 ludovicsclain

[my OS is MacOS Monterey]

Seems it's popular buggy report. You will be asked for config example you not able to pass, if you check [nginx_parser] issues here.

Here is my so called buggy one:

upstream service-backend {
  server backend:80;
}

server {
  listen       80;
  server_name  localhost;

  location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
    try_files $uri /index.html;
  }
  location /api {
    proxy_pass http://ccm-backend;
    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;
    proxy_set_header X-Server-Proto $server_protocol;
  }
}

And the problem is not in upstream name, it can be just an address or name, it seems ngx_http_upstream_module is not something acceptable here.

If I do remove upstream completely, the error will change to WARNING Skip unparseable block: "server"

And if I will take next example:

server {
  listen       80;
  server_name  localhost;

  location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
    try_files $uri /index.html;
  }
}

...it will also fail with warning.

I did try to change py version (2.7.17, 3.7.12) but it did not changed anything. Wat I suppose to try - run it in a Docker image.

dzzk avatar Jan 23 '22 16:01 dzzk

It's broken with pyparsing > 2.4.7 so you need to use pyparsing 2.4.7.

thestinger avatar Feb 25 '22 15:02 thestinger

It's broken with pyparsing > 2.4.7 so you need to use pyparsing 2.4.7.

@thestinger can you guide us how?

wedneyyuri avatar Apr 01 '22 19:04 wedneyyuri

I gave you a working workaround. There's nothing else beyond that.

thestinger avatar Apr 01 '22 20:04 thestinger

Thanks @thestinger. For a few minutes I was not sure how to do this, then it became clear that it would be as simple as manually installing the version of pyparsing.

pip install gixy==0.1.20 pyparsing==2.4.7

wedneyyuri avatar Apr 08 '22 13:04 wedneyyuri

This should really work out-of-the-box. Is there a clear explanation for why it doesn't (e.g. that I have a atypical config)?

My config starts with:

upstream backend {
    server 127.0.0.1:8080;
}

Fastest "fix" for me was:

pip uninstall pyparsing
pip install pyparsing==2.4.7

Darthfett avatar Dec 21 '23 22:12 Darthfett

@Darthfett pyparsing made backwards incompatible changes and unfortunately gixy isn't being actively developed at the moment.

thestinger avatar Dec 21 '23 22:12 thestinger

Understood. Backwards incompatible changes in a non-major release is unfortunate. Opened PR 140 to address it.

Darthfett avatar Dec 22 '23 01:12 Darthfett

@Darthfett It was in a major release. It's pyparsing v3 and beyond that breaks it.

thestinger avatar Dec 22 '23 01:12 thestinger