Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom domain routing to Flask server with custom domain always showing in address bar

I have a small home-server running Flask set up at IP a.b.c.d. I also have a domain name xyz.com.

Now I would like it so that when going to xyz.com, the user is served the content from a.b.c.d, with xyz.com still showing in the address bar. Similarly, when going to xyz.com/foo the content from a.b.c.d/foo should be shown, with xyz.com/foo showing in the address bar.

I have path forwarding activated at my domain name provider, so xyz.com/foo is correctly forwarded to a.b.c.d/foo, but when going there a.b.c.d/foo is shown in the address bar.

I'm currently running tornado, but I can switch to another server if it is necessary.

Is it possible to set up this kind of solution? Or is my only option to buy some kind of hosting?

like image 304
Godsmith Avatar asked Jun 09 '14 15:06

Godsmith


People also ask

How do I assign an IP address to a flask?

Another thing you can do is use the flask executable to start your server, you can use flask run --host=0.0. 0.0 to change the default IP which is 127.0. 0.1 and open it up to non local connections. So If we summarize then the outcome is you should use the app.

What is the default IP address for flask?

Parameters of the flask run command. --host – the IP address of the web server to run your Flask application on. The default value is '127.0. 0.1'.

How do you keep a flask server running?

Make sure, you close the terminal and not press Ctrl + C. This will allow it to run in background even when you log out. To stop it from running , ssh in to the pi again and run ps -ef |grep nohup and kill -9 XXXXX where XXXX is the pid you will get ps command.


1 Answers

I managed to solve it by myself, but I'll add this as an answer since evidently someone thought it was a worthwhile question.

It turns out that it was just me that did not understand how DNS works and what the difference between DNS and domain forwarding is. At most domain hosts you can configure "domain forwarding", which sounds what precisely what you need but is NOT. Rather, for the simple usecase above, I went into the DNS Zone Records in the options and created a DNS Zone Record type A that pointed xyz.com to a.b.c.d. The change does not seem to have propagated entirely yet, but already on some devices I can see it working exactly how I want it to, so I will consider this issue resolved.

like image 58
Godsmith Avatar answered Oct 06 '22 19:10

Godsmith