Code Monkey home page Code Monkey logo

Comments (8)

kissgyorgy avatar kissgyorgy commented on June 22, 2024

1st question, how best to handle www.mydomain.com so that it hits the public schema and doesn't try for a tenant url of 'www'. Is that a rewrite rule?

The middleware removes the www, you can see it here:
https://github.com/bcarneiro/django-tenant-schemas/blob/master/tenant_schemas/middleware.py#L25

from django-tenant-schemas.

fuhrysteve avatar fuhrysteve commented on June 22, 2024

You should be able to make www point to public by simply copying the middleware, modifying it to simply return after connection.set_schema_to_public() if the subdomain is www, and then telling your settings.py to use your custom middleware instead of the tenant_schema middleware as specified here in the docs: https://django-tenant-schemas.readthedocs.org/en/latest/install.html#basic-settings

i.e.:

MIDDLEWARE_CLASSES = (
    'myapp.middleware.WWWPublicTenantMiddleware',
    #...
)

from django-tenant-schemas.

humbled avatar humbled commented on June 22, 2024

Thanks @walkman, @fuhrysteve. Sounds like it might already be handled so I'll wait see before attempting the second solution.

So to the perhaps bigger question then; advice on setting up the tenant subdomain virtual hosts? (ie all subdomains other than www)

Thanks again

from django-tenant-schemas.

fuhrysteve avatar fuhrysteve commented on June 22, 2024

Something like:

<VirtualHost *:80>
    # This first-listed virtual host is also the default for *:80
    ServerName www.example.com
    ServerAlias *.example.com 
    DocumentRoot /www/domain
</VirtualHost>

See: http://httpd.apache.org/docs/current/vhosts/name-based.html

from django-tenant-schemas.

humbled avatar humbled commented on June 22, 2024

@fuhrysteve surely it contains WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py in there at least? As per https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/modwsgi/. I did read the Apache doc pages already, my trouble is just coupling the 2 in the best way. I'll spend some more time on it and post a solution for feedback if it seems to work ok.
Cheers

from django-tenant-schemas.

fuhrysteve avatar fuhrysteve commented on June 22, 2024

You'll basically want what the django docs state, but you'll need *:80 on your VirtualHost and ServerAlias *.example.com within it.

from django-tenant-schemas.

bernardopires avatar bernardopires commented on June 22, 2024

Hi Humbled,

sorry for the late reply. My VirtualHost is very similar to steve's.

<VirtualHost 127.0.0.1:8080>
    ServerName mywebsite.com
    ServerAlias *.mywebsite.com mywebsite.com
    LimitRequestBody 3145728
    # 3MB limit file size
    WSGIDaemonProcess www.mywebsite.com processes=5 threads=1
    WSGIProcessGroup www.mywebsite.com
    WSGIScriptAlias / "/path/to/django/scripts/mywebsite.wsgi"
    # line above means the root folder (/) will load wsgi
</VirtualHost>

I have added it to the docs: 92615d0

Hope this helps!

Cheers,
Bernardo

from django-tenant-schemas.

humbled avatar humbled commented on June 22, 2024

That's great, thanks @fuhrysteve @bcarneiro. Bernardo I ended up with one very similar to what you posted, but I've included python-path argument to WSGIDaemonProcess as per the Django docs. Perhaps you have a system-wide path set elsewhere.

Thanks for adding to the docs, that's what this was all about.

Cheers
Brad

from django-tenant-schemas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.