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

Webserver extras overridden when trying to set auth_basic #35

Closed
djowett opened this issue Mar 18, 2016 · 5 comments
Closed

Webserver extras overridden when trying to set auth_basic #35

djowett opened this issue Mar 18, 2016 · 5 comments

Comments

@djowett
Copy link
Contributor

djowett commented Mar 18, 2016

I've wanted to run up a private demo, so I found I could add auth_basic to the nginx config with the following configuration:

webserver_virtualhosts:
  - hostname: "demo1.mycompany.com"
    default_server: yes
    extra: |
      auth_basic "Private Demo - please enter your credentials";
        auth_basic_user_file /etc/nginx/htpasswd;

Unfortunately, this doesn't work unless I also comment out this line in the nginx role's host template. I notice from the history of that file that item.extra used to be added after that line. Can we revert to that ordering?

@smcmahon
Copy link
Member

I don't want to revert the ordering, as the change was intentional. But, it would be fine to add a location_extra setting that is explicitly targeted for the location section after the proxy_pass clause.

Will that work for you?

@djowett
Copy link
Contributor Author

djowett commented Mar 23, 2016

That would work for me. But it's no trouble just to override it locally
for now - as long as I'm not breaking anything
by commenting out your auth_basic line.

On 22/03/16 22:29, Steve McMahon wrote:

I don't want to revert the ordering, as the change was intentional.
But, it would be fine to add a location_extra setting that is
explicitly targeted for the location section after the proxy_pass clause.

Will that work for you?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#35 (comment)

Daniel Jowett

Jowett Enterprises Ltd
Tel: 0333 3 553 773
Mobile: 07870 667 126
daniel@jowettenterprises.com
www.jowettenterprises.com

@djowett
Copy link
Contributor Author

djowett commented Jul 19, 2016

This fix doesn't work for me unfortunately. I get the following in nginx.

2016/07/19 17:29:33 [emerg] 31936#0: "auth_basic" directive duplicate in /etc/nginx/sites-enabled/http_demob_jowettenterprises_com:20

The following works for me, and gets the indentation a little better, but testing for 'auth_basic ' like this seems wrong, what do you think??

[...]
  location / {
{%     if 'auth_basic ' not in item.get('location_extra', '') %}
    auth_basic off;
{%     endif %}
{%     if item.get('location_extra') != None %}
  {{     item.location_extra }}
{%     endif %}
    rewrite ^/(.*)$ /VirtualHostBase/$vh_protocol/$server_name:$vh_port{{ item.zodb_path }}/VirtualHostRoot/$1 break;
    proxy_pass http://localhost:{{ proxycache_port|default('6081') }};
  }
[...]

@djowett djowett reopened this Jul 20, 2016
@djowett
Copy link
Contributor Author

djowett commented Jul 20, 2016

@smcmahon suggested fix in 3c12e38, but it seems a bit hacky, so if you want to declare this a "wontfix", I'm not troubled by that!

@smcmahon
Copy link
Member

smcmahon commented Oct 4, 2016

The finer parts of the virtual hosting are all going to be hacks. We just need the right ones ;)

@smcmahon smcmahon closed this as completed Oct 4, 2016
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