server {
listen 80;
listen [::]:80;
server_name 88888.com;
rewrite ^ https://888888.com$request_uri? permanent;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/ssl/8888888.crt;
ssl_certificate_key /etc/ssl/8888888.key;
include /etc/nginx/snippets/ssl;
server_name 88888888.com;
if ($host !~* ^(88888888.com)$ ){return 444;}
if ($request_method !~ ^(GET|HEAD|POST)$ ){return 444;}
access_log /var/log/nginx/stp.access.log;
error_log /var/log/nginx/stp.error.log;
client_max_body_size 64m;
location / {
uwsgi_pass unix:///tmp/stp.sock;
include uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
}
location /static/ {
alias /home/alx/stp/static/;
}
location /media/ {
alias /home/alx/stp/static/media/;
}
}
server {
listen 80;
listen [::]:80;
server_name www.88888888.com;
rewrite ^ https://www.88888888.com$request_uri? permanent;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/ssl/8888888.crt;
ssl_certificate_key /etc/ssl/8888888.key;
include /etc/nginx/snippets/ssl;
server_name www.888888888.com;
access_log /var/log/nginx/stp.access.log;
error_log /var/log/nginx/stp.error.log;
client_max_body_size 64m;
location / {
uwsgi_pass unix:///tmp/stp.sock;
include uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
}
location /static/ {
alias /home/alx/stp/static/;
}
location /media/ {
alias /home/alx/stp/static/;
}
}
server {
listen 80;
listen [::]:80;
server_name *.888888888.com;
rewrite ^ https://*.888888888.com$request_uri? permanent;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/ssl/8888888888.crt;
ssl_certificate_key /etc/ssl/88888888.key;
include /etc/nginx/snippets/ssl;
server_name *.8888888888.com;
access_log /var/log/nginx/stp.access.log;
error_log /var/log/nginx/stp.error.log;
client_max_body_size 64m;
location / {
uwsgi_pass unix:///tmp/landing.sock;
include uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
}
location /static/ {
alias /home/alx/stp/static/;
}
location /media/ {
alias /home/alx/stp/static/;
}
}
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp6 0 0 :::80 :::* LISTEN
unix 2 [ ACC ] STREAM LISTENING 28092 /run/user/0/systemd/private
unix 2 [ ACC ] STREAM LISTENING 15080 /tmp/stp.sock
from django.views.decorators.cache import never_cache
@never_cache
def login(request, template="account/login.html", form_class=LoginForm, extra_context=None):
initial = {}
if request.GET.get('email', None):
initial['username'] = request.GET.get('email', None)
form = form_class(request.POST or None, initial=initial)
# raise Exception(request.POST)
if request.method == "POST" and not 'action' in request.POST and form.is_valid():
authenticated_user = form.save()
if authenticated_user is not None:
if authenticated_user.is_active:
info(request, _("Successfully logged in"))
auth_login(request, authenticated_user)
ip_client = get_client_ip(request)
try:
current_ip = IpCurrentUser.objects.get(user=request.user)
current_ip.ip_current = ip_client
except:
IpCurrentUser.objects.create(ip_current=ip_client, user=request.user)
if not request.user.can_register:
return redirect(reverse_lazy('register-presentation'))
return redirect(reverse_lazy('dashboard:dashboard'))
context = {"form": form, "title": _("Log in"), 'recover_form': PasswordResetForm(request.POST or None)}
context.update(extra_context or {})
# raise Exception(settings.SESSION_COOKIE_DOMAIN)
return TemplateResponse(request, template, context)
else:
recover_form = PasswordResetForm(request.POST or None)
if request.method == "POST" and 'action' in request.POST:
form = form_class(initial=initial)
if request.method == "POST" and 'action' in request.POST and recover_form.is_valid():
user = recover_form.save()
send_verification_mail(request, user, "password_reset_verify")
info(request, _("A verification email has been sent with "
"a link for resetting your password."))
context = {"form": form, "title": _("Log in"), 'recover_form': PasswordResetForm(request.POST or None)}
context.update(extra_context or {})
context.update(csrf(request))
# raise Exception(settings.SESSION_COOKIE_DOMAIN)
# return TemplateResponse(request, template, context)
return render_to_response(template, context)
@login_required
def logout(request):
auth_logout(request)
info(request, _("Successfully logged out"))
return redirect(reverse_lazy('login'))