Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

nginx.tmpl: use closest vhost.d and htpasswd files (#1309)#1558

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
jjakob wants to merge1 commit intonginx-proxy:main
base:main
Choose a base branch
Loading
fromjjakob:vhost-htpasswd-closest-match

Conversation

jjakob
Copy link

This changes the logic for finding a matching file to the same one used
by certificates. This allows wildcard host names to find a matching
config file.

The container prints "Template error: open /etc/nginx/htpasswd: no such
file or directory" if /etc/nginx/htpasswd doesn't exist, but this
doesn't impact functionality. A fix would be to make sure that directory
is always created.

Fixes#1309.

@jjakob
Copy link
Author

I'd like this functionality to be merged, as I still use it. But I'm not satisfied with using the 'closest' function, as it matches anywhere inside the filename string, it isn't anchored to the end, so e.g. a file 'b.c' will match 'a.b.c.d'.

I'd want something like a 'closestSuffix' function, which would anchor the match at the end of the string, so for example, only 'b.c.d' or 'c.d' will match 'a.b.c.d'.
This would allow setting vhost.d and htpasswd files for VIRTUAL_HOST with an arbitrary number of subdomains.

I think the only way to implement this is by adding a 'closestSuffix' function to docker-gen, but I don't have time to set up a build environment for it. Perhaps someone could implement the function there, and I could update this pull request to use it?

I'm envisioning something like:

#sameasarrayClosestbutanchoredtotheendofthestringfuncarrayClosestSuffix(values []string,inputstring)string {best:=""for_,v:=rangevalues {ifstrings.HasSuffix(input,v)&&len(v)>len(best) {best=v                }        }returnbest}

This could be further improved by checking that the first subdomain is not a partial match, e.g. 'bc.def' should not match 'abc.def' (with the above function, it will), but at first, it's not necesarry.

In the meantime I will rebase to main and update the PR.
@buchdag

buchdag reacted with eyes emoji

@jjakobjjakobforce-pushed thevhost-htpasswd-closest-match branch from01dfb5b to88e792bCompareJanuary 10, 2025 23:34
@jjakobjjakob marked this pull request as draftJanuary 10, 2025 23:35
@jjakobjjakobforce-pushed thevhost-htpasswd-closest-match branch 2 times, most recently from48b6637 to5fbec43CompareJanuary 11, 2025 21:04
Add logic to find the closest matching files for vhost.d, vhost.d_include and htpasswd files.This allows multiple hosts to share these files, similar to wildcardcertificate files, but not limited to just 1 subdomain depth.The match is anchored to the end of the string filename, so a largestsuffix match is found.For example, 'vhost.d/b.c' will match a 'a.b.c' virtual host.But 'a.b' will not match 'a.b.c'.This is stricter than the "closest" match function that certificatefiles used in the past, which would also match in the 2nd case.This is a WIP, unfinished sections are marked with TODO.
@jjakobjjakobforce-pushed thevhost-htpasswd-closest-match branch from5fbec43 to8adc2ebCompareJanuary 13, 2025 18:53
@buchdag
Copy link
Member

@jjakob I'm not opposed at all to add a function to docker-gen if this can help with a feature here, I'll look into it.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
type/featPR for a new feature
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Check closest host match when looking for vhost.d/config files before checking default
2 participants
@jjakob@buchdag

[8]ページ先頭

©2009-2025 Movatter.jp