问题
I have an app deployed on pythonanywhere and setup to use a custom domain. I'm in the process of getting the domain and I wanted to ask if there is a way to access my application via the CNAME webapp-xxxxxx.pythonanywhere.com which has been provided by pythonanywhere. Currently trying to access it takes me to the coming soon page.
Thank you.
回答1:
A different possibility: if what you mean is that you're going to https://webapp-xxxxxx.pythonanywhere.com directly in your browser, that will always give you a "Coming soon" page. Basically the webapp-xxxxx... domain is just an identifier for the load-balancer associated with your web app. You need to set up the CNAME to get it to work.
If you want to test stuff in the meantime, and you have created a web app on PythonAnywhere with the domain set to the one that you're in the process of acquiring, you can hack your own machine's DNS setup to fool it into thinking that the domain is already purchased and set up:
- Find the IP address of the loadbalancer associated with your web app by running the following from a terminal/command prompt on your local machine:
ping webapp-XXXXXX.pythonanywhere.com
. (Obviously use the exact value you see in the PythonAnywhere web tab, not the one with XXXX in it.) - Open your hosts file, which is
/etc/hosts
on Linux or OS X, orc:\Windows\system32\drivers\etc
on Windows, in a text editor, and add a line with the IP address you got from the previous step, then a tab, then the host name you've set up the web app with in PythonAnywhere. - Save and quit the editor
Once you've done that, you should just be able to visit the host in a browser and it will work. Don't forget to delete the line from your hosts file once you've acquired the domain and set up the CNAME properly.
回答2:
The most likely issue is that you don't have a web app at the domain that you're trying to access. For instance, if you've added the CNAME to www.mydomain.com, you must have a web app at www.mydomain.com. The fact that you're getting a "coming soon" page suggests that the CNAME is correctly set up to go to PythonAnywhere.
来源:https://stackoverflow.com/questions/32308397/access-my-web-app-with-cname