3f1c49ca2c9032e5a01a72dcdcc9aa282b5e71b5
By:
maxgonpe

How do I make my application visible on the web

April 8, 2017 845 views
Development Ubuntu 16.04

And now I have the following situation,

First I do not see any errors, because the commands "sudo nginx -t" and "python3 manage.py runserver localhost: 9000" run well for me and now while running this last command I can access my application that is hosted in "djangoproject" without No change using the djangoproject skeleton and just re-editing the necessary ".py" as urls.py, views.py and add the "html" files of my application. EVERYTHING ALRIGHT HERE. If I give "Control-C", then I can not access my application and send me the error bad 502, but I think this is the right thing, because I am accessing through the test server.

But according to the documentation I made several changes in nginx and gunicorn, which do not produce any effect, because when access by the name of my domain "www.xxxxxxxxxxx.cxx" I continue releasing the page html index.html that is hosted in var / www /xxxxxxxxxxxxxxxxx.cxx / html and is not redirected to my application.

As I mentioned, I followed all the steps of the documentation sent to me.

Please, to achieve success with this, you can give me some additional recommendation. ? To make and work

6 Answers

I'd recommend using a better domain than www.xxxxxxxxxxxxxxxxx.cxx to increase visibility.

sure, I just put that to make it more general, but if you are going to help me and want to see the domain would be www.maxsistemas.cl

Hi @maxgonpe

If I'm understanding you correctly, when you run your project directly with python3 manage.py runserver localhost:9000, you're able to see your site through Nginx?

You need to setup your project through Gunicorn, so that will keep your project running in the background. Then you do the reverse proxy from Nginx to Gunicorn.

Which tutorial have you been following?

Thanks for your interest in helping me, well among so many things I have tried, I lean for these three as the most successful:

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-host-name-with-digitalocean

https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04

https://www.digitalocean.com/community/tutorials/how-to-use-the-django-one-click-install-image

In all the tutorials I have reviewed, do not let me clear the union between what I am doing in my python directory and what is published. good. I hope you give me some way to go. Thanks in advance

by Etel Sverdlov
This article walks you through setting up the DNS for your site. The tutorial includes steps to set up an A records, point your nameservers, and provides some information about MX records.

Hi @maxgonpe

Remember to either use the Reply-link or use the @ to notify others - otherwise it's easy to overlook new comments.

Are you using the Django one-click-app? If yes, then your default path is /home/django/django_project

If not, what/how did you install the server?

  • Thanks friends hansen and woet , I have tried to follow all recommendations that have been granted, but I still stuck and my question is whether it works or not follow the steps of the tutorials to deploy a site python-django-gunicorn-nginx without problems ?

    maybe change and rebuild my droplet with dbian o another operating system, because ubuntu 16.04 ist not working, but ist importa for me that say me is really work python app into ubuntu 16.04 ??

    • @maxgonpe

      But are you using the Django one-click-app then it works. That's a prebuilt image and you just need to add your code.

      You can setup python-django-gunicorn-nginx on any of the operating systems available on DigitalOcean. But it will require some work from you and that's why the one-click-app is the easy test platform.

      • Just that is the point, I tried to use the pre-built image of ubuntu 16.04 with django in which I launched a directory called "django_project" and precisely there at that point, it was impossible to deploy my application on the web always Send me the bad 502, and also I did it and I tried it in three ways one as it is without making any changes and that only I launched the page "its work from django" and I did not function to see the page in my development server But after following the instructions of nginx and gunicorn, nothing of anything just bad 502.

        Also try to put my code inside the folder "django_project" retouching the .py (views, urls, static) with my code, and I could see my application running but at the moment of launching it to the web bad 502

        And also follow all the steps and install according to the tutorial in a new directory "myproject" with your virtual environment, connection to the database postgres and everything works until you try to make it visible on the web, then try to give the configurations to Nginx and gunicorn and the result is the same bad 502.

        That is why my initial question, if anyone of those who saw this post could attest that I had an application running without problems.

        Anyway, I still try, on the one hand this fascinates me and on the other hand I feel frustrated because I can not get out of bad 502. I understand that the one who is doing something wrong is myself, but it is precisely what I want to discover with the help Of you.

        • Hi @maxgonpe
          Have you checked the log files, because this sounds like your app is not starting, which means Nginx will still point to Gunicorn, which is actually not running.

@hansen

if you're right. I am thoroughly reviewing the whole procedure and very carefully. In what with the help of others, manage to start, I will comment on the details of "why?" I did not work, and I hope this is soon, because it is driving me crazy, not being able to achieve my goal.

Thank you. Your contributions I consider and see in that direction related to gunicorn

Have another answer? Share your knowledge.