Fix nginx config

master
Diman0 3 years ago
parent 960033525d
commit b148e41d9b

@ -10,13 +10,17 @@ import flask_login
def login(): def login():
form = forms.LoginForm() form = forms.LoginForm()
endpoint = flask.request.args.get('next', 'ui.index') endpoint = flask.request.args.get('next', 'ui.index')
if endpoint == 'ui.webmail':
endpoint = 'ui.webmail'
else:
endpoint = 'ui.index'
if form.validate_on_submit(): if form.validate_on_submit():
user = models.User.login(form.email.data, form.pw.data) user = models.User.login(form.email.data, form.pw.data)
if user: if user:
flask.session.regenerate() flask.session.regenerate()
flask_login.login_user(user) flask_login.login_user(user)
return flask.redirect(flask.url_for(endpoint) return flask.redirect(flask.url_for(endpoint))
or flask.url_for('ui.index'))
else: else:
flask.flash('Wrong e-mail or password', 'error') flask.flash('Wrong e-mail or password', 'error')
return flask.render_template('login.html', form=form, endpoint=endpoint) return flask.render_template('login.html', form=form, endpoint=endpoint)

@ -1,7 +1,7 @@
# Basic configuration # Basic configuration
user nginx; user nginx;
worker_processes auto; worker_processes auto;
error_log /dev/stderr info; error_log /dev/stderr debug;
pid /var/run/nginx.pid; pid /var/run/nginx.pid;
load_module "modules/ngx_mail_module.so"; load_module "modules/ngx_mail_module.so";
@ -117,17 +117,29 @@ http {
include /overrides/*.conf; include /overrides/*.conf;
# Actual logic # Actual logic
location ^~ /sso {
include /etc/nginx/proxy.conf;
proxy_set_header Host $host;
proxy_pass http://$admin;
}
location ^~ {{ WEB_ADMIN }}/sso { location ^~ {{ WEB_ADMIN }}/sso {
include /etc/nginx/proxy.conf; include /etc/nginx/proxy.conf;
rewrite ^{{ WEB_ADMIN }}/(.*)$ /$1 break; rewrite ^{{ WEB_ADMIN }}/(.*) /$1 redirect;
proxy_set_header Host $host; }
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; 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' %} {% if WEB_WEBMAIL != '/' and WEBROOT_REDIRECT != 'none' %}
location / { location / {

Loading…
Cancel
Save