烧瓶管理页面在人迹罕至的生产 [英] Flask-Admin pages inaccessible in production

查看:187
本文介绍了烧瓶管理页面在人迹罕至的生产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图部署使用Apache和mod_wsgi的一个Ubuntu服务器上我的瓶的应用程序。

I am trying to deploy my Flask app using Apache and mod_wsgi on an Ubuntu server.

这似乎做工精细的,我已经实现了宁静的要求,但我不能访问我的烧瓶管理页面(我可以在发展中访问)。

It seems to work fine for restful requests that I have implemented, but I can't access my Flask-Admin pages (which I can access in development).

下面是我的应用程序的结构(简化这个问题的目的):

Here is the structure of my app (simplified for the purpose of this question) :

- MyApp/
    - main.py
    - myapp/
        - __init__.py
        - Views.py
        - files/
    - wsgi/
        myapp.wsgi

在开发中,我只需使用python main.py,一切工作正常运行。

When in development, I simply run by using python main.py and everything works fine.

下面是WSGI文件:

import sys
import os

##Virtualenv Settings
activate_this = '/var/www/code/MyApp/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

##Replace the standard out
sys.stdout = sys.stderr

##Add this file path to sys.path in order to import settings
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), '../..'))

##Add this file path to sys.path in order to import app
sys.path.append('/var/www/code/MyApp/')

from myapp import app as application

下面是Apache的配置文件,我使用的Apache 2.2:

Here is the configuration file for Apache, I'm using Apache 2.2 :

<VirtualHost *:443>
        WSGIScriptAlias /myapp /var/www/code/MyApp/wsgi/myapp.wsgi
        WSGIScriptReloading On
        WSGIPassAuthorization On

        SSLEngine on
        SSLCertificateFile /var/www/code/MyApp/ssl.crt
        SSLCertificateKeyFile /var/www/code/MyApp/ssl.key
        SSLVerifyClient None
        SSLOptions +StdEnvVars

        <Directory /var/www/code/MyApp/wsgi>
                Order deny,allow
                Allow from all
        </Directory>

</VirtualHost>

下面是我如何实例化瓶应用在我的__ 的init 的__.py:

Here is how I instantiate the Flask app in my __ init __.py :

app = Flask(__name__, static_folder='files')

下面是我在我的main.py创建管理接口:

Here is how I create the Admin interface in my main.py :

# Create admin
admin = admin.Admin(app, 'App Administration')

我也有一个链接到管理页面中我Views.py:

I also have a link to the admin page in my Views.py :

@app.route('/')
def index():
    return '<a href="/admin/">Go to admin page</a>'

在开发中,我可以在mysite.com/admin/访问管理界面。

When in development, I can access the admin interface at mysite.com/admin/ .

在生产,我有我的应用程序在mysite.com/myapp/,我无法进入管理界面,我预计将在mysite.com/myapp/admin/。

In production, I have my app at mysite.com/myapp/ and I can't access the admin interface, which I expected to be at mysite.com/myapp/admin/ .

我觉得有与我实例烧瓶管理员的方式有问题。我保留了默认的admin /URL,但也许我需要在生产时要声明一个特定的网址?

I think there's a problem with the way I instantiate flask-admin. I kept the default "admin/" url but maybe I need to declare a specific url when in production ?

感谢您的帮助。

编辑:

我检查Apache的错误日志,但我没有得到任何错误。

I checked the Apache error log but I don't get any error.

推荐答案

你有没有尝试更新的myapp的路线?看起来你需要更新您的生产路线。甚至可以对​​生产降'/'。试试吧。

Did you try to update your route with "myapp"? Looks like you need to update your route for production. May even be able to drop the '/' on production. Try it.

@app.route('/')
@app.route('/myapp/')
def index():

这篇关于烧瓶管理页面在人迹罕至的生产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆