diff --git a/core/admin/mailu/sso/views/base.py b/core/admin/mailu/sso/views/base.py index 702b1582..9013fb0c 100644 --- a/core/admin/mailu/sso/views/base.py +++ b/core/admin/mailu/sso/views/base.py @@ -10,13 +10,17 @@ import flask_login def login(): form = forms.LoginForm() endpoint = flask.request.args.get('next', 'ui.index') + + if endpoint == 'ui.webmail': + endpoint = 'ui.webmail' + else: + endpoint = 'ui.index' if form.validate_on_submit(): user = models.User.login(form.email.data, form.pw.data) if user: flask.session.regenerate() - flask_login.login_user(user) - return flask.redirect(flask.url_for(endpoint) - or flask.url_for('ui.index')) + flask_login.login_user(user) + return flask.redirect(flask.url_for(endpoint)) else: flask.flash('Wrong e-mail or password', 'error') return flask.render_template('login.html', form=form, endpoint=endpoint) diff --git a/core/nginx/conf/nginx.conf b/core/nginx/conf/nginx.conf index d428b0d0..2ae3bcfb 100644 --- a/core/nginx/conf/nginx.conf +++ b/core/nginx/conf/nginx.conf @@ -1,7 +1,7 @@ # Basic configuration user nginx; worker_processes auto; -error_log /dev/stderr info; +error_log /dev/stderr debug; pid /var/run/nginx.pid; load_module "modules/ngx_mail_module.so"; @@ -117,17 +117,29 @@ http { include /overrides/*.conf; # Actual logic - location ^~ /sso { - include /etc/nginx/proxy.conf; - proxy_set_header Host $host; - proxy_pass http://$admin; - } location ^~ {{ WEB_ADMIN }}/sso { include /etc/nginx/proxy.conf; - rewrite ^{{ WEB_ADMIN }}/(.*)$ /$1 break; - proxy_set_header Host $host; + rewrite ^{{ WEB_ADMIN }}/(.*) /$1 redirect; + } + location ^~ /ui/webmail { + include /etc/nginx/proxy.conf; + return 302 {{ WEB_WEBMAIL }}; + } + location ^~ /ui { + include /etc/nginx/proxy.conf; + #rewrite ^/sso/(.*) {{ WEB_ADMIN }}/$1 redirect; + return 302 {{ WEB_ADMIN }}/ui/; + } + location ^~ /sso { + include /etc/nginx/proxy.conf; proxy_pass http://$admin; } +# location ^~ /(ui|static) { +# rewrite ^{{ WEB_ADMIN }}/(.*) /$1 break; +# include /etc/nginx/proxy.conf; +# proxy_set_header X-Forwarded-Prefix {{ WEB_ADMIN }}; +# proxy_pass http://$admin; +# } {% if WEB_WEBMAIL != '/' and WEBROOT_REDIRECT != 'none' %} location / {