Nginx server configuration devdojo.com

Solved
rvalenzuelaferrada

Jan 3rd, 2022 08:06 PM

Tony, what nginx configuration do you use on the devdojo server? I am especially interested in the part of the blog, where a domain of ricardo.com is redirected to ricardo.devdojo.com.

bobbyiliev

Jan 4th, 2022 12:33 AM

Best Answer

Hi there,

We have a catch-all Nginx server block to catch all of the subdomain names.

You can define this by specifying the following servername:

    server_name .devdojo.com;

The redirect itself is then handled by using the Laravel subdomain routing as described in the official docs here.

Hope that this helps!

Bobby

1
rvalenzuelaferrada

Jan 4th, 2022 06:17 AM

Thank you very much Bobby for your quick response. The configuration that you tell me works perfectly with a subdomain of devdojo, but what happens when the domain is not devdojo? in my account I have the possibility to use my own domain. rvalenzuela.com and when I configure this in cloudflare with the cname to rvalenzuela.devdojo.com it works with my url rvalenzuela.com, that's my question. How in Laravel do you interpret that it is a subdomain, if the url is rvalenzuela.com?

bobbyiliev

Jan 4th, 2022 06:37 AM

Hello,

There could be different ways of doing this, but one way would be to have a model which contains your custom domains and maps them to the respective subdomains / usernames.

rvalenzuelaferrada

Jan 4th, 2022 02:42 PM

Bobby, again very grateful for your answer, helped me a lot to move forward with my project. Researching the best way to do it, I found this article

In case someone else wants to do something similar, for some much more complex things, like multiple databases, you can use this package

thinkverse

Jan 4th, 2022 02:44 PM

You'll want to look up and research; Multitenancy. Specifically, in regards to Laravel, two packages are popular. Those are Tenancy for Laravel by ArchTech and laravel-multitenancy by Spatie.

If you happen to be a PRO member on CodeCourse there is the Laravel Multi-tenancy Basics course. Or if you are a subscriber on Laracasts there's the Multitenancy in Practice course.

Sadly don't know of any free courses on the subject off the top of my head. But you could always search for Laravel multitenancy and see what's out there.

Hope that gives you any ideas. 🙂

Edit: Seems you found what you were looking for as I was writing my answer. 👍 Gonna leave my answer here in-case some other users is looking for the same information.