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

"include" directive is not allowed within an "if" block #505

Closed
dareste opened this issue Oct 17, 2023 · 4 comments
Closed

"include" directive is not allowed within an "if" block #505

dareste opened this issue Oct 17, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@dareste
Copy link
Contributor

dareste commented Oct 17, 2023

The following valid nginx config is mistakenly marked as illegal by the Agent:

server {
    listen       80 default_server;
    server_name  localhost;

    location / {

        if ($request_method = 'OPTIONS') 
        {
          include conf.d/some_file;
          return 204;
        }

        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
}

The agent fails to write the configuration with:

time="2023-10-17T08:47:26Z" level=info msg="Updating NGINX config"
time="2023-10-17T08:47:26Z" level=info msg="Attempting to run command: /usr/sbin/nginx with args -t -c /etc/nginx/nginx.conf"
time="2023-10-17T08:47:26Z" level=info msg="Config validated:\nnginx: the configuration file /etc/nginx/nginx.conf syntax is ok\nnginx: configuration file /etc/nginx/nginx.conf test is successful\n"
time="2023-10-17T08:47:26Z" level=error msg="Config apply failed (write): error running nginx -t -c /etc/nginx/nginx.conf:\n error reading config from /etc/nginx/nginx.conf, error: \"include\" directive is not allowed here in /etc/nginx/conf.d/default.conf:11"

This is caused by a bug in nginx-go-crossplane (see nginxinc/nginx-go-crossplane#72). Once we have a new nginx-go-crossplane version, Agent will have to point to that one to solve this validation issue.

@ja20222 ja20222 added the bug Something isn't working label Oct 17, 2023
@oliveromahony
Copy link
Contributor

I've updated the version of crossplane in #504

Let me know if that resolves the issue

@dareste
Copy link
Contributor Author

dareste commented Oct 17, 2023

@oliveromahony, apologies that I wasn't clear. The latest crossplane version (0.4.32) is still affected by the issue. I have submitted a PR with the fix. Once it's merged and a new crossplane version is bumped, we'll have to change it here.

@dareste
Copy link
Contributor Author

dareste commented Oct 25, 2023

@oliveromahony crossplane 0.4.33 is published and fixes this issue.

@oliveromahony oliveromahony self-assigned this Nov 7, 2023
@oliveromahony
Copy link
Contributor

Merged with #512 - this should be in the next release of the NGINX Agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants