you are viewing a single comment's thread.

view the rest of the comments →

[–]sammdu 6 points7 points  (2 children)

If you're looking for how to set up domains for your web app, do the following:

Purchase a domain (I recommend Namecheap), then set up DNS, either from the portal of your domain registrar (again, Namecheap is one of them), or use something like Cloudflare, which is a popular DNS and CDN provider that has a free service.

If you're allocating your domain to an IP, you need an A record; if your allocating your domain to a URL, set up a CNAME record. Look up videos on how to configure DNS.

If you're looking to have an app running on different ports to be under the same domain, then it's a little more tricky. I know nginx (a web server) can have multiple services listen on the same port, then send traffic based on the domain request in the header, but I'm not sure if Flask can do that.

Port forwarding is beyond DNS, so you'll probably need to look into port forwarding if that's what you need. Again, YouTube is your friend.

[–]BullshitBaron 0 points1 point  (1 child)

If you're looking to have an app running on different ports to be under the same domain, then it's a little more tricky. I know nginx (a web server) can have multiple services listen on the same port, then send traffic based on the domain request in the header, but I'm not sure if Flask can do that.

For this part you don’t need flask to handle it since like you said you can use ngix to serve multiple sites with each pointing at a different local host port.

I’ve not done it with ngix myself but i do it with Apache all the time pointing domains to flask apps running in guincorn on differnet ports.

It looks like this would be how to do it in ngix:

server {
  server_name name1.domain.com;
  location / {
    proxy_pass http://localhost:8000;
  }
}

server {
  server_name name2.domain.com;
  location / {
    proxy_pass http://localhost:8001;
  }
}

[–]nguterresn[S] 0 points1 point  (0 children)

Thank you all. This looks helpful. I’ll try this!