domain/hosting config with nginx & gunicorn for wagtail multi-site

852 views
Skip to first unread message

Dmitry Borisoglebsky

unread,
Sep 29, 2016, 11:22:24 AM9/29/16
to Wagtail support
I would like to ask for directions to setup multiple sites on a single Wagtail installation.

I started by following an approach I built on https://wagtail.io/blog/multi-site-wagtail/ on my local PC, and was successful running multiple sites, e.g. alpha.localhost:8000 and beta.localhost:8000

I run multiple sites on different Wagtail installations by following http://michal.karzynski.pl/blog/2013/10/29/serving-multiple-django-applications-with-nginx-gunicorn-supervisor/ on both my local PC and local server via Dynamic DNS, e.g. localhost:8000 and localhost:8001 or gamma.ddns.net and delta.ddns.net

I however failed to run a mixture of these approaches -- alpha.ddns.net and beta.ddns.net . After few failed attempts I stopped trying after I convinced myself that DynDNS service might utlise a  form of protection against sub-sub-domain abuse (noip.com provides 3 sub-domains for free, e.g. site1.ddns.com). I know though I'm not knowledgeable nor patient enough to prove or disprove this hypothesis.

So, I bought hosting and domain names, via DigitalOcean and namecheap, respectively. I succeeded to get admin panel via IP for a DigitalOcean droplet (host server); was able to create and link root-pages to sites alpha and beta; link namecheap domain names to DigitalOcean. I however get "Welcome to nginx!" message if I open both alpha.com and beta.com

Could you please direct me to the missing bits in my wagtail and/or gunicorn and/or nginx and/or hosting and/or DNS configuration?

Tobias McNulty

unread,
Sep 29, 2016, 12:12:09 PM9/29/16
to wag...@googlegroups.com
Hi Dmitry,

Could you provide a link to your nginx config?

Also (this may become clear with the config), are you hoping to set up HTTP, HTTPS, or both?

Tobias

--
You received this message because you are subscribed to the Google Groups "Wagtail support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wagtail+unsubscribe@googlegroups.com.
To post to this group, send email to wag...@googlegroups.com.
Visit this group at https://groups.google.com/group/wagtail.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wagtail/e4c77332-6ec0-4b83-9883-45ade4f5a5e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Tobias McNulty
Chief Executive Officer

tob...@caktusgroup.com
www.caktusgroup.com

Dmitry Borisoglebsky

unread,
Sep 29, 2016, 12:36:39 PM9/29/16
to Wagtail support

@Tobias, please find my nginx config below.


----------------------
START of the config as located in /etc/nginx/sites-available
----------------------
upstream multi_serve {
  server unix:/webapps/multi/run/gunicorn.sock fail_timeout=0;
}

server {
    listen   80;
    server_name theIPofDigitaloceanDroplet;

    client_max_body_size 8m;

    access_log /webapps/multi/logs/nginx-access.log;
    error_log /webapps/multi/logs/nginx-error.log;

    location /static/ {
        alias   /webapps/multi/static/;
    }

    location /media/ {
        alias   /webapps/multi/media/;
    }

    location /robots.txt {
        alias   /webapps/multi/static/robots.txt;
    }

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        if (!-f $request_filename) {
            proxy_pass http://multi_serve;
            break;
        }
    }
}
----------------------
END of the config
----------------------

Tobias McNulty

unread,
Sep 29, 2016, 12:41:01 PM9/29/16
to wag...@googlegroups.com
You might try listing the specific domains on the server_name line, or using the catch-all signifier '_' as specified here:


As written I'm fairly certain your config will only accept requests if the IP is typed directly into the address bar (you might try that before changing it to test this theory).

Let us know if you find a working config.

Tobias

--
You received this message because you are subscribed to the Google Groups "Wagtail support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wagtail+unsubscribe@googlegroups.com.
To post to this group, send email to wag...@googlegroups.com.
Visit this group at https://groups.google.com/group/wagtail.

For more options, visit https://groups.google.com/d/optout.

Dmitry Borisoglebsky

unread,
Sep 29, 2016, 2:37:35 PM9/29/16
to Wagtail support
START of the config as located in /etc/nginx/sites-available
----------------------
server {
    listen   80;
    server_name alpha.com;

    client_max_body_size 8m;

    access_log /webapps/multi/logs/nginx-access.log;
    error_log /webapps/multi/logs/nginx-error.log;

    location /static/ {
        alias   /webapps/multi/static/;
    }

    location /media/ {
        alias   /webapps/multi/media/;
    }

    location /robots.txt {
        alias   /webapps/multi/static/robots.txt;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/webapps/multi/run/gunicorn.sock;
    }
}

server {
    listen   80;
    server_name beta.com;

    client_max_body_size 8m;

    access_log /webapps/multi/logs/nginx-access.log;
    error_log /webapps/multi/logs/nginx-error.log;

    location /static/ {
        alias   /webapps/multi/static/;
    }

    location /media/ {
        alias   /webapps/multi/media/;
    }

    location /robots.txt {
        alias   /webapps/multi/static/robots.txt;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/webapps/multi/run/gunicorn.sock;
    }
}

Tobias McNulty

unread,
Sep 29, 2016, 2:45:47 PM9/29/16
to wag...@googlegroups.com
Glad it's working. You can also separate server names with a space, unless you need the separate server blocks for some reason.

Don't forget to set up the same list of domains in Django's ALLOWED_HOSTS.

Tobias

--
You received this message because you are subscribed to the Google Groups "Wagtail support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wagtail+unsubscribe@googlegroups.com.
To post to this group, send email to wag...@googlegroups.com.
Visit this group at https://groups.google.com/group/wagtail.

For more options, visit https://groups.google.com/d/optout.

Dmitry Borisoglebsky

unread,
Sep 29, 2016, 4:05:51 PM9/29/16
to Wagtail support
@Tobias, I incline to have domain-specific sitemap.xml and some logs; I yet to check if I could have a dynamically generated sitemap within my setup.  Thank you for the reminder about ALLOWED_HOSTS, I remember now inet recommendations forbidding "*" I have at the moment.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages