Jump to content

Hello, im trying to deal with some messy things with my webs on my mechine, sometimes when i type subdomain that is not in use its shows me a file that is not even asigned to that config and i want to make an site that will redirect people to error site when they enter subdomain that doesnt exist or smth like that.. Any idea?

Link to comment
https://linustechtips.com/topic/1416992-nginx-fallback-site/
Share on other sites

Link to post
Share on other sites

That's called a catch-all subdomain: https://fedingo.com/how-to-setup-catch-all-subdomains-in-nginx/

 

If any subdomain is resolved to your IP, this should work, provided you do not use HTTPS. If you use HTTPS and you do not have a wildcard certificate, a non-existent subdomain will typically result in a certificate error in the browser.

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
https://linustechtips.com/topic/1416992-nginx-fallback-site/#findComment-15296627
Share on other sites

Link to post
Share on other sites

1 hour ago, Eigenvektor said:

That's called a catch-all subdomain: https://fedingo.com/how-to-setup-catch-all-subdomains-in-nginx/

 

If any subdomain is resolved to your IP, this should work, provided you do not use HTTPS. If you use HTTPS and you do not have a wildcard certificate, a non-existent subdomain will typically result in a certificate error in the browser.

but what if the domain is set root @?  google,com

Link to comment
https://linustechtips.com/topic/1416992-nginx-fallback-site/#findComment-15296736
Share on other sites

Link to post
Share on other sites

19 minutes ago, Depstros said:

but what if the domain is set root @?  google,com

I'm not sure what you mean by that.

 

I assume you have a domain like "example.com" and if someone goes to "something.example.com" they do end up on your nginx? Meaning the DNS server does resolve any subdomain to your IP, so you can actually deal with it? If that's not the case, and only specific domains resolve to your IP, then there's nothing you can configure for subdomains you don't control.

 

The result of these two commands should be the same IP

nslookup example.com
nslookup something.example.com

Replace "example.com" with your actual domain. Replace "something" with anything, it should always point to the same IP, i.e. those of your web server. If that's the case, you should be able to set up a catch-all domain on your nginx.

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
https://linustechtips.com/topic/1416992-nginx-fallback-site/#findComment-15296769
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×