Answer the question
In order to leave comments, you need to log in
How to implement user authentication using CNAME?
Hello!
Suppose there is a certain service that provides public content for each user. Clients access it by url, for example, like this: http://myservice.com/userid/usercontent
You can add a CNAME record for the myservice.com domain, like: * CNAME myservice.com
Then, I can accept different domain hosts as a web server, for example: http://userid.myservice.com
So, I’m wondering if there are standard tools and methods on web server level, allowing you to associate the name of the subdomain and the user?
Those. access content as: http://user1.myservice.com/user1content
http://user2.myservice.com/user2content
http://user2.myservice.com/user2content2
etc.
Receive the content of a specific user and at the same time, if possible, do not get into the code of the finished application.
Answer the question
In order to leave comments, you need to log in
Everything is much simpler than I originally thought and can be solved in a couple of lines of the nginx config:
server_name ~^(?<userid>.+)\.myservice\.com$;
root [root_path]/$userid/;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question