[GH-ISSUE #590] Make modoboa work with uwsgi/nginx in a subdirectory #556

Closed
opened 2026-02-27 11:12:23 +03:00 by kerem · 1 comment
Owner

Originally created by @piwats on GitHub (Jul 30, 2014).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/590

Hell there,

Modoboa refuses to work with nginx and uwsgi:

1.) nginx config:

server {
server_name wohooo.com;
listen 80;
listen [::]:80;
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl spdy;
#listen [::]:443 ipv6only=on ssl spdy;
server_name wohooo.com;

    include /etc/nginx/vhosts/ssl.include;

    access_log /var/log/nginx/wohooo.com.ssl_access_log main;
    error_log /var/log/nginx/wohooo.com.ssl_error_log info;

    root /var/www/mail/admin/admin;

    ###
    ###  MODOBOA
    ###
    location /modoboa/sitestatic/ {
            #autoindex on;
            alias /var/www/mail/admin/admin/sitestatic/;
    }

    # Whether or not Modoboa uses a media directory depends on how
    # you configured Modoboa. It does not hurt to have this.
    location /modoboa/media/ {
            #autoindex on;
            alias /var/www/mail/admin/admin/media/;
    }

    # This denies access to any file that begins with
    # ".ht". Apache's .htaccess and .htpasswd are such files. A
    # Modoboa installed from scratch would not contain any such
    # files, but you never know what the future holds.
    location ~ /\.ht {
            deny all;
    }

    location /modoboa {
            #alias /var/www/mail/admin/admin;
            include uwsgi_params;
            uwsgi_pass unix:/run/modoboa.socket;
            uwsgi_param UWSGI_SCRIPT admin.wsgi:application;
            uwsgi_param UWSGI_SCHEME https;
            #uwsgi_param SCRIPT_NAME /modoboa;
    }

}

2.) uwsgi config file:

[uwsgi]

Not needed when using uwsgi from pip

plugins = python27
chdir = /var/www/mail/admin/
module = admin.wsgi:application
master = true
harakiri = 30
sharedarea = 4
processes = 4
vhost = true
no-default-app = true

3.) Settingd from settings.py:

LOGIN_URL = '/modoboa/accounts/login/'
MEDIA+SITESTATIC PATHS set according to nginx conf.

THE ERRORS I GET:

Page not found (404)
Request Method: POST
Request URL: https://wohooo.com/modoboa/accounts/login/
Using the URLconf defined in admin.urls, Django tried these URL patterns, in this order:
^$
^jsi18n/$
^accounts/login/$
^accounts/logout/$
^core/$
^core/parameters/$
^core/parameters/save/$
^core/extensions/$
^core/extensions/save/$
^core/info/$
^core/logs/$
^user/$
^user/preferences/$
^user/profile/$
^user/forward/
^admin/
^postfix_relay_domains/
^limits/
^webmail/
^stats/
^sfilters/
^quarantine/
^modoboa/sitestatic/(?P.)$
^modoboa/media/(?P.
)$
The current URL, modoboa/accounts/login/, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

Originally created by @piwats on GitHub (Jul 30, 2014). Original GitHub issue: https://github.com/modoboa/modoboa/issues/590 Hell there, Modoboa refuses to work with nginx and uwsgi: 1.) nginx config: server { server_name wohooo.com; listen 80; listen [::]:80; return 301 https://$server_name$request_uri; } server { listen 443 ssl spdy; #listen [::]:443 ipv6only=on ssl spdy; server_name wohooo.com; ``` include /etc/nginx/vhosts/ssl.include; access_log /var/log/nginx/wohooo.com.ssl_access_log main; error_log /var/log/nginx/wohooo.com.ssl_error_log info; root /var/www/mail/admin/admin; ### ### MODOBOA ### location /modoboa/sitestatic/ { #autoindex on; alias /var/www/mail/admin/admin/sitestatic/; } # Whether or not Modoboa uses a media directory depends on how # you configured Modoboa. It does not hurt to have this. location /modoboa/media/ { #autoindex on; alias /var/www/mail/admin/admin/media/; } # This denies access to any file that begins with # ".ht". Apache's .htaccess and .htpasswd are such files. A # Modoboa installed from scratch would not contain any such # files, but you never know what the future holds. location ~ /\.ht { deny all; } location /modoboa { #alias /var/www/mail/admin/admin; include uwsgi_params; uwsgi_pass unix:/run/modoboa.socket; uwsgi_param UWSGI_SCRIPT admin.wsgi:application; uwsgi_param UWSGI_SCHEME https; #uwsgi_param SCRIPT_NAME /modoboa; } ``` } 2.) uwsgi config file: [uwsgi] # Not needed when using uwsgi from pip plugins = python27 chdir = /var/www/mail/admin/ module = admin.wsgi:application master = true harakiri = 30 sharedarea = 4 processes = 4 vhost = true no-default-app = true 3.) Settingd from settings.py: LOGIN_URL = '/modoboa/accounts/login/' MEDIA+SITESTATIC PATHS set according to nginx conf. THE ERRORS I GET: Page not found (404) Request Method: POST Request URL: https://wohooo.com/modoboa/accounts/login/ Using the URLconf defined in admin.urls, Django tried these URL patterns, in this order: ^$ ^jsi18n/$ ^accounts/login/$ ^accounts/logout/$ ^core/$ ^core/parameters/$ ^core/parameters/save/$ ^core/extensions/$ ^core/extensions/save/$ ^core/info/$ ^core/logs/$ ^user/$ ^user/preferences/$ ^user/profile/$ ^user/forward/ ^admin/ ^postfix_relay_domains/ ^limits/ ^webmail/ ^stats/ ^sfilters/ ^quarantine/ ^modoboa\/sitestatic\/(?P<path>._)$ ^modoboa\/media\/(?P<path>._)$ The current URL, modoboa/accounts/login/, didn't match any of these. You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
kerem closed this issue 2026-02-27 11:12:23 +03:00
Author
Owner

@piwats commented on GitHub (Aug 2, 2014):

Finally a solution:

add

uwsgi_param SCRIPT_NAME /<subdirs_name>;
uwsgi_modifier1 30;

to the /<subdirs_name> location

:)

-Enchancement to docs

<!-- gh-comment-id:50955775 --> @piwats commented on GitHub (Aug 2, 2014): Finally a solution: add uwsgi_param SCRIPT_NAME /<subdirs_name>; uwsgi_modifier1 30; to the /<subdirs_name> location :) -Enchancement to docs
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#556
No description provided.