-
Notifications
You must be signed in to change notification settings - Fork 18
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
Allowed list of domains #147
Comments
Hello. You can do it by deny all domains in blacklist, then allow good domains in whitelist lets-proxy2/cmd/static/default-config.toml Lines 130 to 137 in f97f3a9
|
Hey Timofey - can you please give us an example at how you use the Whitelist config? For example, if I only wanted the following domains to be allowed: domainone.com Do you just use an array for example:
Or, is there another way to do this. Thanks |
Hello, @brandymedia. WhiteList/BlackList is one string with one regexp. Regexp syntax described at https://github.com/google/re2/wiki/Syntax for your scenation you can write one of:
Double backslash need because toml parser use \ as backslash too. If you will use simple dot instead of "\." - dot will match with any symbol. It will work, but will not strong correct (regexp www.test.ru will allow domains wwwbtest.ru). |
Hey Timofeym I have tried to add a whitelist as per your example but for some reason it still allows other subdomains. So for example, I only want to accept www and the naked domain, but not anything.domainone.com for instance. I need to prevent multiple subdomains accessing and thus creating certificates if that makes sense. |
For instance, I am getting lots of ones like this: sber.gitlab.r5fg6uqvkdxvod4.auth.domainone.com.ecdsa.cer Which eventually makes the service stop. |
Ow, it may by confused by blacklist/whitelist rules. Do you have blacklist rules? If you want use whitelist only - you have to add BlackList=".*" (deny all). I add more explain to config and tests with PR https://github.com/rekby/lets-proxy2/pull/213/files Is it solve your question? |
Thanks Timofey, that make sense - I appreciate your fast response and solution. I'm currently testing this to see if I can prevent all the spammy certificates. Is there a way to remove the current certificates for a domain, so I can test whether the blacklist/whitelist is working? I tried removing the files in the storage folder, but no new ones are added from that domain when I visit the website? Do I need to remove them from somewhere else? Thanks for your help. |
remove storage folder is ok way. Did you restart the proxy?
No, the proxy doesn't store anything outside from storage folder. |
Yes, I did restart the service but then no new files are created for the domain I had removed in the storage... but it still seems to load fine over https which is confusing... I'm getting hit by tons of requests from what I can only imagine is a wildcard subdomain which is trying to create certificates. Looking at the logs, it is now 'denying' those requests. However, I have removed the files for certain domains which should be blocked, but they still serve over https. |
Okay, it looks like removing the files from storage, restarting has now worked on one of the domain. It is still however letting in files like: mail.www.domainone.com.ecdsa.cer I've set Blackilist to: BlackList=".*" And whitelist to: WhiteList = "domainone\.com|www.domainone\.com As I only want to allow the www and naked versions. Not any other random subdomain. Thanks |
try to use marks of start/end string, because regexp "domain.com" mean string with domain contains "domain.com". But can has some prefix and ending.
optional subdomain you can make by:
|
Thanks again. So in the second example
Does that work with multiple domain names but restrict to only www and naked domain? So for instance:
Is that correct syntax? |
So for example, I only want this to work with:
etc |
yes, it must work |
I think I had an erro in my syntax... it should be:
Hopefully that will work now. Out of interest, is there a way to actually prevent the subdomains requesting certificates at all? Currently they request and get denied. Thanks again. |
It contains double-escaped dots, try use one slash:
What mean "prevent the subdomains requesting certificates"? |
It was the one slash that was throwing the error. It seemed to work with the 2 slashes. Sorry, reg ex is not my speciality 🙈 I'll test this now and let you know the outcome. |
Unfortunately now I can not get a certificate for a domain on the www or naked. I removed all occurrences of that domain in the storage folder and now it won't add new ones for that domain. Do you think this could be down to limits? |
Ho Timofey, Still working on this and I'm getting an error for a domain I am trying to get a certificate for.
This was one of the domains that was issuing lots of certificates on subdomains - I removed them all from storage and now it won't create a new one for the www or naked version. Do you know what this error is please? |
@brandymedia, try update lets-proxy up to v0.29.3, I have added authorisation details to the error. |
@rekby cool. Can you remind me of the process? Is it a case of removing everything and the reuploading the new binary and reconfiguring everything? Thanks again. |
You should replace binary (and restart it) only. |
Hey @rekby. Still struggling to get the whitelist to work. I have set in the config file:
But it's still allowing other subdomains which means the server is getting spammed on subdomains creating too many requests which then brings the service down. I only want to accept www or blank. Thanks for your assistance. |
As a follow up question, does lets-proxy run before or after accessing the vhosts file in Linux Ubuntu? Trying to find a way to stop spurious subdomains from creating hundreds/thousands of certificates. Wondering whether by removing the default vhost which catches all requests that don't have a specific vhost would help or not..? |
The rules should work fine. Similar rule checked by test. You can write actual config and example of domain, which must be denied by rules, but allowed by real. I will check it by the test. If it isn't help to detect problem I will need debug log for issue certificate for one of bad subdomain. |
Thanks Timofey, Here is an example of the config file:
When I look in the storage directory there are hundred if not thousands of certificates for subdomains on these domains I do not want. Thanks again. |
Can show write one of them for check by rules by hands, by test, debug on the example, etc? Better one of latest domain. You can grep it from a log by string "Certificate issued." or command |
I have checked the latest files using The latest one on this server is - Mar 7 08:44 yandex.avito.pay.pay.r5fg6uqvkdxvod4.www.auth.ama-uk.com.ecdsa.cer Although on some of the servers these are getting created much quicker. What do I need to do to test this manually please? |
For example on another of our servers we have many records created in the same minute:
|
I've had a lot of ratelimiting because of clients that send bogus HTTPS requests:
It would be nice to limit the specific names and patterns that will receive a certificate to avoid being ratelimited.
The text was updated successfully, but these errors were encountered: