I am serving multiple websites using nginx and gunicorn and I would like to add another one. Sadly my lack of experience is limiting me, I have some experience with webdesign but always struggle on the server side...|-( (I am using Django because of my Python preference in scientific analysis).
My problem: The new site seems to refer to the port used by another. Checking the gunicorn status I see that the site is running although nginx seems to be unable to refer to the correct Django folder. Could someone point me in the right direction? I have been looking around for the last hour or so...
(I didn't include any code for now as I am not sure where the error might lie at this point...)
Next day update: So I finally came across a post mentioning that the origin of the error might lie on the browser side. I deleted my recent history, this has fixed the error. I believe I somehow loaded a https certificate belonging to one of the other sites, this is no longer the case!
I came across the solution, it was a browser side fix. The answer is provided in an update to the original question.
Related
I created a "landing page website" using Django, it's a very simple website for using just for showing up the data with no query sets that coming from the database it's just 3 or 4 queries.
I'm using the Nginx server for deploying and everything working properly but just the loading of the page is very very slow, I don't know where can I find the issue. I thought that the problem might become from Nginx since it has the ability to manage static files and also, I thought about maybe droplet cause such that issue.
my brain is frozen about finding the core of that problem where I can't think of where the problem may happen so, how can I accelerate my web page, and what are the reasons for that problem?
I don't know if StackOverflow is a good choice to ask such that question or not but I will be grateful for solving that problem in advance
Let me preface this by saying that my knowledge on django and web development in general is very superficial.
I was messing around with security configs on my django project, trying to make my website use https (which since then I learned is not that easy to do) but I got it into a redirect loop I believe (the website never loads). I tried to revert all my changes but couldn't get to run the website locally. After looking for answers on google in vain I decided to start the project from scratch (I had just started it anyway). But now even that doesn't work, even the Writing your first app tutorial doesn't work.
After that I reinstalled python and all the dependencies expecting that to clear every possible thing that I had changed but it didn't, still the same problem, websites never load trying to use https.
Where else could the problem in my system be?
Deleted cache and cookies and it solved the problem.
So, I am writing a django-mongo app, using mongo for storing files as well, and using the python files mongoforms and mongoengine. Things were going well for a while, but just recently I have started to get 504 errors. I am using nginx -> apache (mod_wsgi) for non-static files.
Other (non-mongo) django apps on the same server are working, as are static html pages served up by ngnix. Also, if I turn off mongodb entirely, I get the normal django debug=True error page, so when mongo is just turned off it seems that nginx, apache, and django are all able to function.
However, with mongo in the picture I am now unable to get a response. I am able to use the command line interface to mongo, and although I'm only using the 32b version, it says that I'm only using 0.0625GB for the database in question.
So, I realize this isn't enough information to figure out what my problem is, but that's more or less what I'm looking for: where do I look next? I can connect to mongo, but not via django, although I used to be able to. I've tried commenting out virtually the entire django view, just leaving the index call which is not even asking for anything from mongo, so what I'm looking for is where do I look next? Are there any debugging techniques for mongo where I can figure out why it's taking so long to respond to django? Any other ways to debug this?
I don't expect anyone to miraculously solve my problem here but telling me what info to look for next would help as I don't have much experience debugging the django-mongo connection. It worked at one time but it has stopped working and I'm not sure where to look.
I just started developing in Django a few days back. After finishing a few applications I read that Django is best served using nginx for static content and a reverse proxy to apache for dynamic contents. Is there a particular reason that this configuration preferred over any other?
Also, although this seems to be the standard approach I havent yet been able to find a proper tutorial or document that walks through such a configuration. Most seem to be incomplete/non-working.
It would be great if someone could explain to me how this is to be done or point in the right direction or maybe link a tutorial here.
Thanks in advance.
I suggest to use nginx and gunicorn/uwsgi configuration, it more common this days and easier to setup/configure that apache. A proper tutorials can be found here:
1) django + gunicorn and a more complete tutorial with supervisor, fabric here
2) django + uwsgi
I'm following through the Django Tutorials by HackedExistence on youtube.
Since the video is about a year old, I assume that the version differences may contribute to this problem. I'm currently on the 2nd video but this issue arose since the first.
On my browser,
http://video1.hackedexistence.com/
This link opens up the Apache 2 Test Page, and the localhost link opens up the Django Administrator page nicely.
But he sets it up so that the hacked existence link loads up the Django Admin page.
How is he able to achieve this? and what steps are needed for setting it up that way with the versions that I'm working with.
Python 2.7.3, Django 1.4.1, Apache 2.2.22 (Unix)
Running on OS X 10.6.8.
video1.hackedexistence.com is (presumably) a domain under the control of HackedExistence, and it's showing an Apache 2 test page because the server it's pointing to is not configured to show anything else. You have no control over this domain or the server it is pointing to, so you can't affect it directly.
It doesn't have anything to do with different versions of python, django, apache, or anything else; it's likely that HackedExistence chose to move on to something else, is no longer maintaining his site (or at least the content on that subdomain of it) and his tutorial now no longer works as a result.
The closest you can come is add an entry to your /private/etc/hosts file (on OSX) so that video1.hackedexistence.com resolves to 127.0.0.1 (i.e. localhost, your own computer), but this is almost certainly not what you're after. For example, if you do this, everybody else will still see the test page you're seeing now, because the /etc/hosts file is just telling your computer to treat the video1.hackedexistence.com domain as if it's pointing to your computer.
For learning web development, you can safely completely disregard this and can continue to test on your local computer.
When it comes to deploying the website for other people to view and use, you will need to buy a domain (e.g. at http://namecheap.com/), get some hosting (for python/django hosting I can recommend WebFaction , or you can use Heroku's free plan), and follow the Django deployment instructions in the official documentation (or the documentation provided by the hosting provider you choose). My advice is to focus on learning web development and get something working before you spend money on any hosting.
I don't know the videos, but I'm assuming that the author of the book owns (or owned at the time) the hackedexistence.com domain name, and had it pointing to his server so that it would be able to interpret the Django App and serve it up to public requests ... and now it looks like that configuration doesn't exist any more.
If you're asking what I think you want to ask, "how can I get a Django app viewable on the public web," well, there are lots of ways to go about doing this. If your server is Apache, https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/ is the way to go. Google could help you find the similar docs for other servers. Lots of answers on stack overflow as well.
If instead you're asking a different question, namely, "how can I get this app on my local machine to be viewable via some method other than localhost" (and you don't have a server), well, the answer is you'd have to get a domain that points to your local machine -- this is a question that has lots of answers elsewhere. One thing to be aware of is that Django through Apache on Mac OS X isn't terribly simple, as it requires manually installing mod_wsgi, but it's not overly difficult either. Here's Google's top link (a bit old but still relevant): http://jessenoller.com/2009/07/24/django-mod_wsgi-apache-and-os-x-do-it/
And finally, if you're asking how you can get your app to show up at hacked existence, well ... buy that domain and see the above paragraph. :)