How to configure NGINX to run Django app in a subpath?

2017-11-26 Thread Luca Moiana
Hi,

Sorry for the slight OT but after days of search I have no clue.


Following this DigitalOcean tutorial 

 I 
was able to setup Django + Postgres + Gunicorn + NGINX running Django on my 
root,

Now I'd like to change and have something like this:

mydomain.com -> static HTML
mydomain.com/pmapp -> Django app

I created two server blocks in NGINX, one for my static website:

server {

listen 80;

listen [::]:80;



root /var/www/html/officinecartografiche.it;

index index.html index.htm index.nginx-debian.html;



server_name www.officinecartografiche.it, officinecartografiche.it, 
207.154.206.172;



location / {

try_files $uri $uri/ =404;

   }

}

 and one for my django app:

server {

listen 80;

listen [::]:80;

server_name www.officinecartografiche.it, officinecartografiche.it, 
207.154.206.172;

location = /favicon.ico { access_log off; log_not_found off; }

location /static/ {

root /home/geouser/pmapp;

}



location /pmapp {

#include proxy_params;

proxy_pass http://unix:/home/geouser/pmapp/pmapp.sock;

proxy_redirect http://www.officinecartografiche.it:8000/pmapp/ 
http://$host/pmapp/;

proxy_set_header SCRIPT_NAME /pmapp;

}

}

and added this to settings.py:

FORCE_SCRIPT_NAME = *'/pmapp'*


WHAT AM I DOING WRONG??

THANKS FOR YOUR HELP!!!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b1ee39d2-fd04-4727-88e1-e130def5dd37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to configure NGINX to run Django app in a subpath?

2017-11-27 Thread Luca Moiana
Thanks for your replly, I'll look into the link you suggested.
As for the routing / urls adding FORCE_SCRIPT_NAME = '/pmapp' to 
settings.py isnt' enough?



Il giorno domenica 26 novembre 2017 21:42:41 UTC+1, Matemática A3K ha 
scritto:
>
> I don't know / remember how to do it in Gunicorn, but here is an example 
> with uWSGI:
>
> https://stackoverflow.com/questions/35792409/nginx-serving-django-in-a-subdirectory-through-uwsgi
>
> The main thing is that you will have to deal with "/pmapp" prefix in your 
> routing / urls. You can deal with this inside Django or have it stripped 
> before it gets to Django (by nginx or gunicorn).
>
> HTH :)
>
> On Sun, Nov 26, 2017 at 4:56 PM, Luca Moiana  > wrote:
>
>> Hi,
>>
>> Sorry for the slight OT but after days of search I have no clue.
>>
>>
>> Following this DigitalOcean tutorial 
>> <https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04>
>>  I 
>> was able to setup Django + Postgres + Gunicorn + NGINX running Django on my 
>> root,
>>
>> Now I'd like to change and have something like this:
>>
>> mydomain.com -> static HTML
>> mydomain.com/pmapp -> Django app
>>
>> I created two server blocks in NGINX, one for my static website:
>>
>> server {
>>
>> listen 80;
>>
>> listen [::]:80;
>>
>>
>>
>> root /var/www/html/officinecartografiche.it;
>>
>> index index.html index.htm index.nginx-debian.html;
>>
>>
>>
>> server_name www.officinecartografiche.it, officinecartografiche.
>> it, 207.154.206.172;
>>
>>
>>
>> location / {
>>
>> try_files $uri $uri/ =404;
>>
>>}
>>
>> }
>>
>>  and one for my django app:
>>
>> server {
>>
>> listen 80;
>>
>> listen [::]:80;
>>
>> server_name www.officinecartografiche.it, officinecartografiche.it, 
>> 207.154.206.172;
>>
>> location = /favicon.ico { access_log off; log_not_found off; }
>>
>> location /static/ {
>>
>> root /home/geouser/pmapp;
>>
>> }
>>
>>
>>
>> location /pmapp {
>>
>> #include proxy_params;
>>
>> proxy_pass http://unix:/home/geouser/pmapp/pmapp.sock;
>>
>> proxy_redirect http://www.officinecartografiche.it:8000/pmapp/ 
>> http://$host/pmapp/;
>>
>> proxy_set_header SCRIPT_NAME /pmapp;
>>
>> }
>>
>> }
>>
>> and added this to settings.py:
>>
>> FORCE_SCRIPT_NAME = *'/pmapp'*
>>
>>
>> WHAT AM I DOING WRONG??
>>
>> THANKS FOR YOUR HELP!!!
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/b1ee39d2-fd04-4727-88e1-e130def5dd37%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/b1ee39d2-fd04-4727-88e1-e130def5dd37%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f2799f0e-faba-463d-82f8-308382886006%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to configure NGINX to run Django app in a subpath?

2017-11-27 Thread Luca Moiana
Thanks for your reply, although it sounds hard for a noob like me.

Just to understand, the trick should be done on Gunicorn or on NGINX ?

Il giorno lunedì 27 novembre 2017 11:29:01 UTC+1, Matemática A3K ha scritto:
>
> That's good to know, I tried to do it some time ago, it was an attempt of 
> a "sort-of-tennats" which at the didn't go so I stop doing it. At that 
> moment, I remember trying with gunicorn without success and I was near 
> success with uWSGi but didn't make it at that time. I supposed that know 
> would be solved as the s-o question reports success.
>
> Seems that the easiest way to go is to prefix all urls in Django with the 
> mount point - provided that no url is hardcoded in the django project - and 
> use a "regular" nginx conf...
>
> On Mon, Nov 27, 2017 at 7:09 AM, Etienne Robillard  > wrote:
>
>> I have not been able to solve this problem with uWSGI. Apparently, uWSGI 
>> is not using the same internal routing semantics than FastCGI.
>>
>> See: https://forum.nginx.org/read.php?2,275684,275706
>> Etienne
>>
>>
>> Le 2017-11-26 à 15:41, Matemática A3K a écrit :
>>
>> I don't know / remember how to do it in Gunicorn, but here is an example 
>> with uWSGI:
>>
>> https://stackoverflow.com/questions/35792409/nginx-serving-django-in-a-subdirectory-through-uwsgi
>>
>> The main thing is that you will have to deal with "/pmapp" prefix in your 
>> routing / urls. You can deal with this inside Django or have it stripped 
>> before it gets to Django (by nginx or gunicorn).
>>
>> HTH :)
>>
>> On Sun, Nov 26, 2017 at 4:56 PM, Luca Moiana > > wrote:
>>
>>> Hi, 
>>>
>>> Sorry for the slight OT but after days of search I have no clue.
>>>
>>>
>>> Following this DigitalOcean tutorial 
>>> <https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04>
>>>  I 
>>> was able to setup Django + Postgres + Gunicorn + NGINX running Django on my 
>>> root,
>>>
>>> Now I'd like to change and have something like this:
>>>
>>> mydomain.com -> static HTML
>>> mydomain.com/pmapp -> Django app
>>>
>>> I created two server blocks in NGINX, one for my static website:
>>>
>>> server {
>>>
>>> listen 80;
>>>
>>> listen [::]:80;
>>>
>>>
>>>
>>> root /var/www/html/officinecartografiche.it;
>>>
>>> index index.html index.htm index.nginx-debian.html;
>>>
>>>
>>>
>>> server_name www.officinecartografiche.it, officinecartografiche.
>>> it, 207.154.206.172;
>>>
>>>
>>>
>>> location / {
>>>
>>> try_files $uri $uri/ =404;
>>>
>>>}
>>>
>>> }
>>>
>>>  and one for my django app:
>>>
>>> server {
>>>
>>> listen 80;
>>>
>>> listen [::]:80;
>>>
>>> server_name www.officinecartografiche.it, officinecartografiche.it, 
>>> 207.154.206.172;
>>>
>>> location = /favicon.ico { access_log off; log_not_found off; }
>>>
>>> location /static/ {
>>>
>>> root /home/geouser/pmapp;
>>>
>>> }
>>>
>>>
>>>
>>> location /pmapp {
>>>
>>> #include proxy_params;
>>>
>>> proxy_pass http://unix:/home/geouser/pmapp/pmapp.sock;
>>>
>>> proxy_redirect http://www.officinecartografiche.it:8000/pmapp/ 
>>> http://$host/pmapp/;
>>>
>>> proxy_set_header SCRIPT_NAME /pmapp;
>>>
>>> }
>>>
>>> }
>>>
>>> and added this to settings.py:
>>>
>>> FORCE_SCRIPT_NAME = *'/pmapp'*
>>>
>>>
>>> WHAT AM I DOING WRONG??
>>>
>>> THANKS FOR YOUR HELP!!!
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com .
>>> To post to this group, send email to django...@googlegroups.com 
>>> .
>>> Visit this group at https://groups.google.com/group/django-users.
>>

Re: How to configure NGINX to run Django app in a subpath?

2017-11-27 Thread Luca Moiana
Thanks, I read you tutorial but I don't get where I should set my subpath?

thanks a lot


Il giorno domenica 26 novembre 2017 21:06:56 UTC+1, k2527806 ha scritto:
>
> https://jee-appy.blogspot.com/2017/01/deply-django-with-nginx.html
>
> On Sun, Nov 26, 2017 at 11:26 PM, Luca Moiana  > wrote:
>
>> Hi,
>>
>> Sorry for the slight OT but after days of search I have no clue.
>>
>>
>> Following this DigitalOcean tutorial 
>> <https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04>
>>  I 
>> was able to setup Django + Postgres + Gunicorn + NGINX running Django on my 
>> root,
>>
>> Now I'd like to change and have something like this:
>>
>> mydomain.com -> static HTML
>> mydomain.com/pmapp -> Django app
>>
>> I created two server blocks in NGINX, one for my static website:
>>
>> server {
>>
>> listen 80;
>>
>> listen [::]:80;
>>
>>
>>
>> root /var/www/html/officinecartografiche.it;
>>
>> index index.html index.htm index.nginx-debian.html;
>>
>>
>>
>> server_name www.officinecartografiche.it, officinecartografiche.
>> it, 207.154.206.172;
>>
>>
>>
>> location / {
>>
>> try_files $uri $uri/ =404;
>>
>>}
>>
>> }
>>
>>  and one for my django app:
>>
>> server {
>>
>> listen 80;
>>
>> listen [::]:80;
>>
>> server_name www.officinecartografiche.it, officinecartografiche.it, 
>> 207.154.206.172;
>>
>> location = /favicon.ico { access_log off; log_not_found off; }
>>
>> location /static/ {
>>
>> root /home/geouser/pmapp;
>>
>> }
>>
>>
>>
>> location /pmapp {
>>
>> #include proxy_params;
>>
>> proxy_pass http://unix:/home/geouser/pmapp/pmapp.sock;
>>
>> proxy_redirect http://www.officinecartografiche.it:8000/pmapp/ 
>> http://$host/pmapp/;
>>
>> proxy_set_header SCRIPT_NAME /pmapp;
>>
>> }
>>
>> }
>>
>> and added this to settings.py:
>>
>> FORCE_SCRIPT_NAME = *'/pmapp'*
>>
>>
>> WHAT AM I DOING WRONG??
>>
>> THANKS FOR YOUR HELP!!!
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/b1ee39d2-fd04-4727-88e1-e130def5dd37%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/b1ee39d2-fd04-4727-88e1-e130def5dd37%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eeb0942a-eb58-4399-a3cf-1f978501c660%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to configure NGINX to run Django app in a subpath?

2017-11-27 Thread Luca Moiana
Googling around I found this 
page http://albertoconnor.ca/hosting-django-under-different-locations.html 
but ain't working for me

Il giorno lunedì 27 novembre 2017 11:10:50 UTC+1, Etienne Robillard ha 
scritto:
>
> I have not been able to solve this problem with uWSGI. Apparently, uWSGI 
> is not using the same internal routing semantics than FastCGI.
>
> See: https://forum.nginx.org/read.php?2,275684,275706
> Etienne
>
> Le 2017-11-26 à 15:41, Matemática A3K a écrit :
>
> I don't know / remember how to do it in Gunicorn, but here is an example 
> with uWSGI:
>
> https://stackoverflow.com/questions/35792409/nginx-serving-django-in-a-subdirectory-through-uwsgi
>
> The main thing is that you will have to deal with "/pmapp" prefix in your 
> routing / urls. You can deal with this inside Django or have it stripped 
> before it gets to Django (by nginx or gunicorn).
>
> HTH :)
>
> On Sun, Nov 26, 2017 at 4:56 PM, Luca Moiana  > wrote:
>
>> Hi, 
>>
>> Sorry for the slight OT but after days of search I have no clue.
>>
>>
>> Following this DigitalOcean tutorial 
>> <https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04>
>>  I 
>> was able to setup Django + Postgres + Gunicorn + NGINX running Django on my 
>> root,
>>
>> Now I'd like to change and have something like this:
>>
>> mydomain.com -> static HTML
>> mydomain.com/pmapp -> Django app
>>
>> I created two server blocks in NGINX, one for my static website:
>>
>> server {
>>
>> listen 80;
>>
>> listen [::]:80;
>>
>>
>>
>> root /var/www/html/officinecartografiche.it;
>>
>> index index.html index.htm index.nginx-debian.html;
>>
>>
>>
>> server_name www.officinecartografiche.it, officinecartografiche.
>> it, 207.154.206.172;
>>
>>
>>
>> location / {
>>
>> try_files $uri $uri/ =404;
>>
>>}
>>
>> }
>>
>>  and one for my django app:
>>
>> server {
>>
>> listen 80;
>>
>> listen [::]:80;
>>
>> server_name www.officinecartografiche.it, officinecartografiche.it, 
>> 207.154.206.172;
>>
>> location = /favicon.ico { access_log off; log_not_found off; }
>>
>> location /static/ {
>>
>> root /home/geouser/pmapp;
>>
>> }
>>
>>
>>
>> location /pmapp {
>>
>> #include proxy_params;
>>
>> proxy_pass http://unix:/home/geouser/pmapp/pmapp.sock;
>>
>> proxy_redirect http://www.officinecartografiche.it:8000/pmapp/ 
>> http://$host/pmapp/;
>>
>> proxy_set_header SCRIPT_NAME /pmapp;
>>
>> }
>>
>> }
>>
>> and added this to settings.py:
>>
>> FORCE_SCRIPT_NAME = *'/pmapp'*
>>
>>
>> WHAT AM I DOING WRONG??
>>
>> THANKS FOR YOUR HELP!!!
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/b1ee39d2-fd04-4727-88e1-e130def5dd37%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/b1ee39d2-fd04-4727-88e1-e130def5dd37%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com .
> To post to this group, send email to django...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CA%2BFDnhLuJEm4kE1D1FHMApW8nYQv%2BWi1Xt9R7o07bgOwqLGsjw%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/django-users/CA%2BFDnhLuJEm4kE1D1FHMApW8nYQv%2BWi1Xt9R7o07bgOwqLGsjw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> -- 
> Etienne robillardtka...@yandex.com 
> https://www.isotopesoftware.ca/
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d15cf9a9-9f60-49c4-ad6b-b89ad2f78cde%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to configure NGINX to run Django app in a subpath?

2017-11-29 Thread Luca Moiana
Following this tutorial

I came up with this NGINX server:

upstream app_name {

   server unix:/home/geouser/pmapp/pmapp.sock fail_timeout=10;

}


server {


   listen 80;

  root /home/geouser/pmapp;

  server_name www.officinecartografiche.it, officinecartografiche.it, 
207.154.206.172;



   location /pmapp/ {

 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

 proxy_set_header Host $http_host;

 proxy_redirect off;

 proxy_pass http://app_name/;


}

}

and I can access the "it works" page from: http://my domain/pmapp

But, If I try http://my domain/pmapp/admin

I have error 404

then if I use www.mydomain/pmapp I have "DisallowedHost at /" error but I 
added all possibile spell of my site, including IP, on 'ALLOWED_HOSTS' in 
settings.py

Any help?


Il giorno lunedì 27 novembre 2017 21:28:55 UTC+1, Matemática A3K ha scritto:
>
> Something like this should work:
> https://stackoverflow.com/a/20998131/8930660
> and change STATIC_URL and MEDIA_URL
>
> Also, the FORCE_SCRIPT_NAME should also work, but if it doesn't, the first 
> is the most "manual" thing you can do, I think...
>
> Then you have no need to have 2 nginx confs, just put that the proxy_pass 
> "starts" in your prefix instead of root
>
> On Mon, Nov 27, 2017 at 8:32 AM, Luca Moiana  > wrote:
>
>> Googling around I found this page 
>> http://albertoconnor.ca/hosting-django-under-different-locations.html 
>> but ain't working for me
>>
>> Il giorno lunedì 27 novembre 2017 11:10:50 UTC+1, Etienne Robillard ha 
>> scritto:
>>>
>>> I have not been able to solve this problem with uWSGI. Apparently, uWSGI 
>>> is not using the same internal routing semantics than FastCGI.
>>>
>>> See: https://forum.nginx.org/read.php?2,275684,275706
>>> Etienne
>>>
>>> Le 2017-11-26 à 15:41, Matemática A3K a écrit :
>>>
>>> I don't know / remember how to do it in Gunicorn, but here is an example 
>>> with uWSGI:
>>>
>>> https://stackoverflow.com/questions/35792409/nginx-serving-django-in-a-subdirectory-through-uwsgi
>>>
>>> The main thing is that you will have to deal with "/pmapp" prefix in 
>>> your routing / urls. You can deal with this inside Django or have it 
>>> stripped before it gets to Django (by nginx or gunicorn).
>>>
>>> HTH :)
>>>
>>> On Sun, Nov 26, 2017 at 4:56 PM, Luca Moiana  wrote:
>>>
>>>> Hi, 
>>>>
>>>> Sorry for the slight OT but after days of search I have no clue.
>>>>
>>>>
>>>> Following this DigitalOcean tutorial 
>>>> <https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04>
>>>>  I 
>>>> was able to setup Django + Postgres + Gunicorn + NGINX running Django on 
>>>> my 
>>>> root,
>>>>
>>>> Now I'd like to change and have something like this:
>>>>
>>>> mydomain.com -> static HTML
>>>> mydomain.com/pmapp -> Django app
>>>>
>>>> I created two server blocks in NGINX, one for my static website:
>>>>
>>>> server {
>>>>
>>>> listen 80;
>>>>
>>>> listen [::]:80;
>>>>
>>>>
>>>>
>>>> root /var/www/html/officinecartografiche.it;
>>>>
>>>> index index.html index.htm index.nginx-debian.html;
>>>>
>>>>
>>>>
>>>> server_name www.officinecartografiche.it, officinecartografiche
>>>> .it, 207.154.206.172;
>>>>
>>>>
>>>>
>>>> location / {
>>>>
>>>> try_files $uri $uri/ =404;
>>>>
>>>>}
>>>>
>>>> }
>>>>
>>>>  and one for my django app:
>>>>
>>>> server {
>>>>
>>>> listen 80;
>>>>
>>>> listen [::]:80;
>>>>
>>>> server_name www.officinecartografiche.it, officinecartografiche.it, 
>>>> 207.154.206.172;
>>>>
>>>> location = /favicon.ico { access_log off; log_not_found off; }
>>>>
>>>> location /static/ {
>>>>
>>>> root /home/geouser/pmapp;
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> location /pmapp {
>>

Re: How to configure NGINX to run Django app in a subpath?

2017-11-30 Thread Luca Moiana
Nothing wrong, but havign set up the system I didn't want to change 
software cause I'm not that savvy.
Anyway, I ended up hiring someone on Fivrr and  got the job done. I was 
closed, but not closed enough

Thank for you help !!!

Il giorno mercoledì 29 novembre 2017 22:56:37 UTC+1, Etienne Robillard ha 
scritto:
>
> Whats wrong in using FastCGI for your specific use-case ? 
> Etienne
>
> Le 2017-11-29 à 15:45, Luca Moiana a écrit :
>
> Following this tutorial 
>
> I came up with this NGINX server:
>
> upstream app_name {
>
>server unix:/home/geouser/pmapp/pmapp.sock fail_timeout=10;
>
> }
>
>
> server {
>
>
>listen 80;
>
>   root /home/geouser/pmapp;
>
>   server_name www.officinecartografiche.it, officinecartografiche.it, 
> 207.154.206.172;
>
>
>
>location /pmapp/ {
>
>  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>
>  proxy_set_header Host $http_host;
>
>  proxy_redirect off;
>
>  proxy_pass http://app_name/;
>
>
> }
>
> }
>
> and I can access the "it works" page from: http://my domain/pmapp
>
> But, If I try http://my domain/pmapp/admin
>
> I have error 404
>
> then if I use www.mydomain/pmapp I have "DisallowedHost at /" error but I 
> added all possibile spell of my site, including IP, on 'ALLOWED_HOSTS' in 
> settings.py
>
> Any help?
>
>
> Il giorno lunedì 27 novembre 2017 21:28:55 UTC+1, Matemática A3K ha 
> scritto: 
>>
>> Something like this should work:
>> https://stackoverflow.com/a/20998131/8930660
>> and change STATIC_URL and MEDIA_URL
>>
>> Also, the FORCE_SCRIPT_NAME should also work, but if it doesn't, the 
>> first is the most "manual" thing you can do, I think...
>>
>> Then you have no need to have 2 nginx confs, just put that the proxy_pass 
>> "starts" in your prefix instead of root
>>
>> On Mon, Nov 27, 2017 at 8:32 AM, Luca Moiana  wrote:
>>
>>> Googling around I found this page 
>>> http://albertoconnor.ca/hosting-django-under-different-locations.html 
>>> but ain't working for me
>>>
>>> Il giorno lunedì 27 novembre 2017 11:10:50 UTC+1, Etienne Robillard ha 
>>> scritto: 
>>>>
>>>> I have not been able to solve this problem with uWSGI. Apparently, 
>>>> uWSGI is not using the same internal routing semantics than FastCGI.
>>>>
>>>> See: https://forum.nginx.org/read.php?2,275684,275706
>>>> Etienne
>>>>
>>>> Le 2017-11-26 à 15:41, Matemática A3K a écrit :
>>>>
>>>> I don't know / remember how to do it in Gunicorn, but here is an 
>>>> example with uWSGI:
>>>>
>>>> https://stackoverflow.com/questions/35792409/nginx-serving-django-in-a-subdirectory-through-uwsgi
>>>>
>>>> The main thing is that you will have to deal with "/pmapp" prefix in 
>>>> your routing / urls. You can deal with this inside Django or have it 
>>>> stripped before it gets to Django (by nginx or gunicorn).
>>>>
>>>> HTH :)
>>>>
>>>> On Sun, Nov 26, 2017 at 4:56 PM, Luca Moiana  
>>>> wrote:
>>>>
>>>>> Hi, 
>>>>>
>>>>> Sorry for the slight OT but after days of search I have no clue.
>>>>>
>>>>>
>>>>> Following this DigitalOcean tutorial 
>>>>> <https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04>
>>>>>  I 
>>>>> was able to setup Django + Postgres + Gunicorn + NGINX running Django on 
>>>>> my 
>>>>> root,
>>>>>
>>>>> Now I'd like to change and have something like this:
>>>>>
>>>>> mydomain.com -> static HTML
>>>>> mydomain.com/pmapp -> Django app
>>>>>
>>>>> I created two server blocks in NGINX, one for my static website:
>>>>>
>>>>> server {
>>>>>
>>>>> listen 80;
>>>>>
>>>>> listen [::]:80;
>>>>>
>>>>>
>>>>>
>>>>> root /var/www/html/officinecartografiche.it;
>>>>>
>>>>> index index.html index.htm index.nginx-debian.html;
>>>>>
>>>>>
>>>>>
>>>>> server_name www.officinecartografiche.it, 

Polymorphic class and geomodels?

2015-10-26 Thread Luca Moiana


Hi, working on my first django app, and run into a problem.

I tend to create geodjango objects, and add all data from external tables 
with pk.

Then I want to have different geometries 8points, lines, polygons) into a 
unique polymorphic class, can I do that?

I have an error that I'll document later, and I'm trying to figure out what 
to do.

Here is the model:
import datetime

from django.db import models
from django.contrib.gis.db import models as geomodels
from django.utils import timezone
from django.forms import ModelForm
from polymorphic import PolymorphicModel

# Geometria linea da monitorare
class geolinea(geomodels.Model):
progetto = models.CharField(max_length=14, primary_key=True)
geom = geomodels.MultiLineStringField()
objects = geomodels.GeoManager()
def __str__(self):
return '%s' % (self.progetto)
# Oggetto Progetto soggetto a PMA
class linea(models.Model):
progetto = models.ForeignKey(geolinea)
nome = models.CharField(max_length=200)
TENSIONE = (
('132', '132kV'),
('150', '150kV'),
('220', '220kV'),
('380', '380kV'),
)
tensione = models.CharField(max_length=5,
choices=TENSIONE)
def __str__(self):
return '%s' % (self.nome)

# Geometria dei pdm
class pdmpunto(geomodels.Model):
linea = models.ForeignKey(linea)
numero = models.CharField(max_length=3)
geom = geomodels.PointField()
objects = geomodels.GeoManager()

class pdmtransetto(geomodels.Model):
linea = models.ForeignKey(linea)
numero = models.CharField(max_length=3)
geom = geomodels.LineStringField()
objects = geomodels.GeoManager()

class pdmarea(geomodels.Model):
linea = models.ForeignKey(linea)
numero = models.CharField(max_length=3)
geom = geomodels.PolygonField()
objects = geomodels.GeoManager()

class pdm(PolymorphicModel):
numero = models.CharField(max_length=14, primary_key=True)
class punto(pdm):
rifpunto = models.ForeignKey(pdmpunto)
class transetto(pdm):
riftransetto = models.ForeignKey(pdmtransetto)
class area(pdm):
rifarea = models.ForeignKey(pdmarea)



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3f016213-a4a4-4ae4-9145-46ca19bace1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Polymorphic class and geomodels?

2016-02-05 Thread Luca Moiana
Hi Collin,

Sorry for the late reply, but I still don't get the google groups;

Yes, I am tryng to crete a models where you can choose between the three 
geometry types.

I'll go back to my app and test the code you suggested and post again the 
error.

thanks

On Wednesday, October 28, 2015 at 7:00:26 PM UTC+1, Collin Anderson wrote:
>
> Hello,
>
> Are you trying to combine multiple models into one, like this?
>
> class PolyModel(pdmpunto, pdmtransetto, pdmarea):
> pass
>
> You could also try asking on the geodjango list: 
> http://groups.google.com/group/geodjango
>
> Collin
>
> On Monday, October 26, 2015 at 7:18:24 AM UTC-4, Luca Moiana wrote:
>>
>> Hi, working on my first django app, and run into a problem.
>>
>> I tend to create geodjango objects, and add all data from external tables 
>> with pk.
>>
>> Then I want to have different geometries 8points, lines, polygons) into a 
>> unique polymorphic class, can I do that?
>>
>> I have an error that I'll document later, and I'm trying to figure out 
>> what to do.
>>
>> Here is the model:
>> import datetime
>>
>> from django.db import models
>> from django.contrib.gis.db import models as geomodels
>> from django.utils import timezone
>> from django.forms import ModelForm
>> from polymorphic import PolymorphicModel
>>
>> # Geometria linea da monitorare
>> class geolinea(geomodels.Model):
>> progetto = models.CharField(max_length=14, primary_key=True)
>> geom = geomodels.MultiLineStringField()
>> objects = geomodels.GeoManager()
>> def __str__(self):
>> return '%s' % (self.progetto)
>> # Oggetto Progetto soggetto a PMA
>> class linea(models.Model):
>> progetto = models.ForeignKey(geolinea)
>> nome = models.CharField(max_length=200)
>> TENSIONE = (
>> ('132', '132kV'),
>> ('150', '150kV'),
>> ('220', '220kV'),
>> ('380', '380kV'),
>> )
>> tensione = models.CharField(max_length=5,
>> choices=TENSIONE)
>> def __str__(self):
>> return '%s' % (self.nome)
>>
>> # Geometria dei pdm
>> class pdmpunto(geomodels.Model):
>> linea = models.ForeignKey(linea)
>> numero = models.CharField(max_length=3)
>> geom = geomodels.PointField()
>> objects = geomodels.GeoManager()
>>
>> class pdmtransetto(geomodels.Model):
>> linea = models.ForeignKey(linea)
>> numero = models.CharField(max_length=3)
>> geom = geomodels.LineStringField()
>> objects = geomodels.GeoManager()
>>
>> class pdmarea(geomodels.Model):
>> linea = models.ForeignKey(linea)
>> numero = models.CharField(max_length=3)
>> geom = geomodels.PolygonField()
>> objects = geomodels.GeoManager()
>>
>> class pdm(PolymorphicModel):
>> numero = models.CharField(max_length=14, primary_key=True)
>> class punto(pdm):
>> rifpunto = models.ForeignKey(pdmpunto)
>> class transetto(pdm):
>> riftransetto = models.ForeignKey(pdmtransetto)
>> class area(pdm):
>> rifarea = models.ForeignKey(pdmarea)
>>
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cd243d25-0aff-446d-b9c9-cb5682d9bdf3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Polymorphic class and geomodels?

2016-02-05 Thread Luca Moiana
Hi Serge,

thank you for your reply.

I'm working on an environmental monitoring app, where I want to store, and 
serve, monitoring value on different geometries, points, tracks or polygon.
That's why I'm trying to use a polymorphic model in order to have one 
entity and multiple geometries.

Cheers

L


On Friday, February 5, 2016 at 10:51:31 AM UTC+1, Sergiy Khohlov wrote:
>
>  I would like as simple question :  Are you planning  to have some 
> advantages using this abstract class ? 
>  I’m working on  similar product  (look like you are making energy 
> pipeline system based on postgis and gjango). My product is GTS system 
> which includes POINTS (datas are received via GTS devices mounted on 
> vehicles). Polylines (car route for selected time range),  etc.  Producing 
> abstract class can decrease DB productivity. Which one functional do you 
> need in case of abstract class for different types usage ? 
>
> Many thanks,
>
> Serge
>
>
> +380 636150445
> skype: skhohlov
>
> On Fri, Feb 5, 2016 at 11:07 AM, Luca Moiana  > wrote:
>
>> Hi Collin,
>>
>> Sorry for the late reply, but I still don't get the google groups;
>>
>> Yes, I am tryng to crete a models where you can choose between the three 
>> geometry types.
>>
>> I'll go back to my app and test the code you suggested and post again the 
>> error.
>>
>> thanks
>>
>>
>> On Wednesday, October 28, 2015 at 7:00:26 PM UTC+1, Collin Anderson wrote:
>>>
>>> Hello,
>>>
>>> Are you trying to combine multiple models into one, like this?
>>>
>>> class PolyModel(pdmpunto, pdmtransetto, pdmarea):
>>> pass
>>>
>>> You could also try asking on the geodjango list: 
>>> http://groups.google.com/group/geodjango
>>>
>>> Collin
>>>
>>> On Monday, October 26, 2015 at 7:18:24 AM UTC-4, Luca Moiana wrote:
>>>>
>>>> Hi, working on my first django app, and run into a problem.
>>>>
>>>> I tend to create geodjango objects, and add all data from external 
>>>> tables with pk.
>>>>
>>>> Then I want to have different geometries 8points, lines, polygons) into 
>>>> a unique polymorphic class, can I do that?
>>>>
>>>> I have an error that I'll document later, and I'm trying to figure out 
>>>> what to do.
>>>>
>>>> Here is the model:
>>>> import datetime
>>>>
>>>> from django.db import models
>>>> from django.contrib.gis.db import models as geomodels
>>>> from django.utils import timezone
>>>> from django.forms import ModelForm
>>>> from polymorphic import PolymorphicModel
>>>>
>>>> # Geometria linea da monitorare
>>>> class geolinea(geomodels.Model):
>>>> progetto = models.CharField(max_length=14, primary_key=True)
>>>> geom = geomodels.MultiLineStringField()
>>>> objects = geomodels.GeoManager()
>>>> def __str__(self):
>>>> return '%s' % (self.progetto)
>>>> # Oggetto Progetto soggetto a PMA
>>>> class linea(models.Model):
>>>> progetto = models.ForeignKey(geolinea)
>>>> nome = models.CharField(max_length=200)
>>>> TENSIONE = (
>>>> ('132', '132kV'),
>>>> ('150', '150kV'),
>>>> ('220', '220kV'),
>>>> ('380', '380kV'),
>>>> )
>>>> tensione = models.CharField(max_length=5,
>>>> choices=TENSIONE)
>>>> def __str__(self):
>>>> return '%s' % (self.nome)
>>>>
>>>> # Geometria dei pdm
>>>> class pdmpunto(geomodels.Model):
>>>> linea = models.ForeignKey(linea)
>>>> numero = models.CharField(max_length=3)
>>>> geom = geomodels.PointField()
>>>> objects = geomodels.GeoManager()
>>>>
>>>> class pdmtransetto(geomodels.Model):
>>>> linea = models.ForeignKey(linea)
>>>> numero = models.CharField(max_length=3)
>>>> geom = geomodels.LineStringField()
>>>> objects = geomodels.GeoManager()
>>>>
>>>> class pdmarea(geomodels.Model):
>>>> linea = models.ForeignKey(linea)
>>>> numero = models.CharField(max_length=3)
>>>> ge

Re: Polymorphic class and geomodels?

2016-02-05 Thread Luca Moiana
Hi Serge,

sorry for the expert warning you gave me on performance. But I have trouble 
following your really techincal suggestion, my goal is to have one table 
with measures that is related to three models with different geometries, so 
I can't use a foreign key in measure table, I don't understand the use of 
related obj, can you point me to a good source ?

thanks

On Friday, February 5, 2016 at 7:40:53 PM UTC+1, Sergiy Khohlov wrote:
>
> I’ve decided  to use  connection via key. and using via  key directly or 
>  via related objects.  Such us Car  -> Point  (multiline). Reason is simple 
> : django creates not perfect database structure  and I would like think 
> about performance as soon as possible.  My project contains Car and points 
> related to the car and of course route (POLYLINE).  I deceided to use 
> trivial PostGIS model for avoiding  bottleneck that use simple code in 
> view.  It is really easy to change view and hard to change models in case 
> of important data present. (Every 100km generates 2000 points which cause 
> and route length and motor service interval). In case of success Abstract 
> class (with good performance) let me know please.  
>
> Many thanks,
>
> Serge
>
>
> +380 636150445
> skype: skhohlov
>
> On Fri, Feb 5, 2016 at 7:25 PM, Luca Moiana  > wrote:
>
>> Hi Serge,
>>
>> thank you for your reply.
>>
>> I'm working on an environmental monitoring app, where I want to store, 
>> and serve, monitoring value on different geometries, points, tracks or 
>> polygon.
>> That's why I'm trying to use a polymorphic model in order to have one 
>> entity and multiple geometries.
>>
>> Cheers
>>
>> L
>>
>>
>> On Friday, February 5, 2016 at 10:51:31 AM UTC+1, Sergiy Khohlov wrote:
>>>
>>>  I would like as simple question :  Are you planning  to have some 
>>> advantages using this abstract class ? 
>>>  I’m working on  similar product  (look like you are making energy 
>>> pipeline system based on postgis and gjango). My product is GTS system 
>>> which includes POINTS (datas are received via GTS devices mounted on 
>>> vehicles). Polylines (car route for selected time range),  etc.  Producing 
>>> abstract class can decrease DB productivity. Which one functional do you 
>>> need in case of abstract class for different types usage ? 
>>>
>>> Many thanks,
>>>
>>> Serge
>>>
>>>
>>> +380 636150445
>>> skype: skhohlov
>>>
>>> On Fri, Feb 5, 2016 at 11:07 AM, Luca Moiana  wrote:
>>>
>>>> Hi Collin,
>>>>
>>>> Sorry for the late reply, but I still don't get the google groups;
>>>>
>>>> Yes, I am tryng to crete a models where you can choose between the 
>>>> three geometry types.
>>>>
>>>> I'll go back to my app and test the code you suggested and post again 
>>>> the error.
>>>>
>>>> thanks
>>>>
>>>>
>>>> On Wednesday, October 28, 2015 at 7:00:26 PM UTC+1, Collin Anderson 
>>>> wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>> Are you trying to combine multiple models into one, like this?
>>>>>
>>>>> class PolyModel(pdmpunto, pdmtransetto, pdmarea):
>>>>> pass
>>>>>
>>>>> You could also try asking on the geodjango list: 
>>>>> http://groups.google.com/group/geodjango
>>>>>
>>>>> Collin
>>>>>
>>>>> On Monday, October 26, 2015 at 7:18:24 AM UTC-4, Luca Moiana wrote:
>>>>>>
>>>>>> Hi, working on my first django app, and run into a problem.
>>>>>>
>>>>>> I tend to create geodjango objects, and add all data from external 
>>>>>> tables with pk.
>>>>>>
>>>>>> Then I want to have different geometries 8points, lines, polygons) 
>>>>>> into a unique polymorphic class, can I do that?
>>>>>>
>>>>>> I have an error that I'll document later, and I'm trying to figure 
>>>>>> out what to do.
>>>>>>
>>>>>> Here is the model:
>>>>>> import datetime
>>>>>>
>>>>>> from django.db import models
>>>>>> from django.contrib.gis.db import models as geomodels
>>>>>> from django.utils import timezone
>>>>>>