烧瓶:不断得到404错误

时间:2016-11-29 17:49:49

标签: python nginx flask

我在尝试访问www.root.com/website时遇到404错误(示例)。 Flask会渲染错误处理程序,但请不要使用' /'路线或我在应用程序中定义的任何其他。这曾经在几个月前工作:

app.py:

import os
import datetime

from flask import Flask, render_template, redirect, url_for, session
from flask import jsonify
from flask_oauthlib.client import OAuth

from mod_db import db
from mod_form import form

application = Flask(__name__)
application.debug = False
WTF_CSRF_ENABLED = True
dir_route = str(os.path.dirname(os.path.realpath(__file__)))
base_dir = '' + dir_route.split('/')[-1]

[...]

@application.route('/')
def index():
    return render_template('cover.html', bd=base_dir)

@application.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404

nginx config:

server {
    listen 80;
    server_name root.com www.root.com;
        # Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name root.com www.root.com;
    root /var/www/KRAKEN/public;
    error_log /var/www/KRAKEN/public/nginx.error.log;
    ssl_certificate /etc/letsencrypt/live/root.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/root.com/privkey.pem;
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;
    ssl_session_tickets off;
    # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
    ssl_dhparam /etc/nginx/dhparam.pem;
    # modern configuration. tweak to your needs.
    ssl_protocols TLSv1.2;
    ssl_ciphers 'yadayada';
    ssl_prefer_server_ciphers on;

    # HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months)
    add_header Strict-Transport-Security max-age=15768000;
    # OCSP Stapling ---
    # fetch OCSP records from URL in ssl_certificate and cache them
    ssl_stapling on;
    ssl_stapling_verify on;


    ssl_trusted_certificate /etc/letsencrypt/live/root.com/fullchain.pem;
    resolver 8.8.8.8 8.8.4.4;

        location / {
                index index.php index.html index.htm;
    }
        location /website {
                include uwsgi_params;
                uwsgi_pass unix:///run/uwsgi/website.sock;
        }
        location /website/static {
                root /var/www/KRAKEN/public/website/static/;
    }

    location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
        expires 365d;
    }
}

应用程序结构:

的/ var / WWW /海妖/公共/网站/

.
├── app.py
├── website.ini
├── bin
├── include
├── lib
├── mod_db
├── mod_form
├── multimedia
├── static
├── templates
└── uwsgi.log

0 个答案:

没有答案