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?
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.
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'.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With