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

'Cannot create a location reference without' rather annoying and blocks some possibilities #1074

Closed
dol opened this issue Apr 12, 2017 · 3 comments

Comments

@dol
Copy link
Contributor

dol commented Apr 12, 2017

The following example is not possible due to the current check of the locations paramters in

fail("Cannot create a location reference without a www_root, proxy, location_alias, stub_status, fastcgi, uwsgi, location_custom_cfg, internal, try_files, location_allow, or location_deny defined in ${server}:${title}")

nginx::nginx_servers:
    myserver:
        server_name:
            - 'foobar.example.com'
        listen_port: 80
        www_root: /var/www/web
        use_default_location: false
        locations:
            foobar_deny_root:
                www_root: ~
                index_files: []
                location: /
                location_custom_cfg:
                    return: 301 $scheme://$server_name/testfile
            testfile:
                www_root: ~
                index_files: []
                location: '= /testfile'

This would generate a config file like this.

# MANAGED BY PUPPET
server {
  listen *:80;
  server_name           foobar.example.com;

  root /var/www/web;
  access_log            /var/log/nginx/myserver.access.log main;
  error_log             /var/log/nginx/myserver.error.log;

  location / {
    return 301 $scheme://$server_name/testfile;
  }

  location = /testfile {
  }
}

But this is not possible, because the following error occurs:

Cannot create a location reference without a www_root, proxy, location_alias, stub_status, fastcgi, uwsgi, location_custom_cfg, internal, try_files, location_allow, or location_deny

I understand that this check was needed in combination with use_default_location to prevent the misconfiguration of the default location.

My suggestion to this problem:
Remove the restriction in the location.pp file and move the check to the server.pp file.
Apply the check where the context switch is made.

@dol
Copy link
Contributor Author

dol commented Apr 12, 2017

This check was introduced 6 years ago and was since then altered from this commit: ebd481d

I don't see any usefulness having this check in the location part. Does @jfryman or someone else know the origin of this check.
Looking into the history I see the following pattern:
The check was 6 years ago introduced. Since then a random number of additional parameters where added to the list by various people. Most of them where like 'Add parameter xyz to check' like d838228

We can go on with this pattern by adding more arguments until we end up having all the resource parameters in the list.

nginx allows it to define an empty location header. There is no need to add something to the location body.

@dol
Copy link
Contributor Author

dol commented Apr 12, 2017

I think a remove of the check gains more then having the check moved the server use_default_location context switch.

@juniorsysadmin
Copy link
Member

Fixed by #1075

@alexjfisher alexjfisher changed the title 'Cannot create a location reference without' rahter anoying and blocks some possibilities 'Cannot create a location reference without' rather annoying and blocks some possibilities Aug 1, 2017
cegeka-jenkins pushed a commit to cegeka/puppet-nginx that referenced this issue Sep 13, 2019
Rubueno pushed a commit to Rubueno/puppet-nginx that referenced this issue Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants