2016-07-12 10 views
2

フラスコを使用してWeb APIを作成しました。私はmod_wsgi-expressを使用してそれを展開しています。同じサーバーに接続していると、Webサイトに簡単に接続できる問題があります。しかし、私は外部からウェブサイトに接続しようとします。このサイトは、私はこれは私が、端末から実行するコマンドである右python2.7.3mod_wsgi-expressで作成したサイトが応答に時間がかかります

へのmod_wsgiをインストール応答する時間がかかりすぎると何もエラー・ログ・ファイルやアクセスログファイル

で言及されていない

mod_wsgi-express start-server configure.wsgi --server-root /home/xarxes_ub/python_code/Error_log/ --user www-data --group www-data --host serverIP --port 8000 
Configure.wsgiコマンドラインが生成セットアップアプリケーション(Iは、完全性のために、以下にそれを挿入)

from MenuUB2 import app as application 

import sys 
sys.stdout = sys.stderr 

ある

mod_wsgi-start-serverは、それがいる可能性があり、私はそれが簡単にあなたたち

ここ
<IfModule !version_module> 
LoadModule version_module '${MOD_WSGI_MODULES_DIRECTORY}/mod_version.so' 
</IfModule> 

ServerName 161.116.80.72 
ServerRoot '/home/xarxes_ub/python_code/Error_log/' 
PidFile '/home/xarxes_ub/python_code/Error_log/httpd.pid' 

ServerTokens ProductOnly 
ServerSignature Off 

User ${MOD_WSGI_USER} 
Group ${MOD_WSGI_GROUP} 

<IfDefine MOD_WSGI_WITH_LISTENER_HOST> 
Listen 161.116.80.72:8000 
</IfDefine> 
<IfDefine !MOD_WSGI_WITH_LISTENER_HOST> 
Listen 8000 
</IfDefine> 


LockFile '/home/xarxes_ub/python_code/Error_log//accept.lock' 


<IfDefine MOD_WSGI_COMPRESS_RESPONSES> 
<IfModule !deflate_module> 
LoadModule deflate_module '${MOD_WSGI_MODULES_DIRECTORY}/mod_deflate.so' 
</IfModule> 
</IfDefine> 

<IfDefine MOD_WSGI_AUTH_USER> 
<IfModule !auth_basic_module> 
LoadModule auth_basic_module '${MOD_WSGI_MODULES_DIRECTORY}/mod_auth_basic.so' 
</IfModule> 
<IfModule !auth_digest_module> 
LoadModule auth_digest_module '${MOD_WSGI_MODULES_DIRECTORY}/mod_auth_digest.so' 
</IfModule> 
<IfModule !authz_user_module> 
LoadModule authz_user_module '${MOD_WSGI_MODULES_DIRECTORY}/mod_authz_user.so' 
</IfModule> 
</IfDefine> 

<IfDefine MOD_WSGI_WITH_PROXY> 
<IfModule !proxy_module> 
LoadModule proxy_module ${MOD_WSGI_MODULES_DIRECTORY}/mod_proxy.so 
</IfModule> 
<IfModule !proxy_http_module> 
LoadModule proxy_http_module ${MOD_WSGI_MODULES_DIRECTORY}/mod_proxy_http.so 
</IfModule> 
</IfDefine> 

<IfModule mpm_prefork_module> 
<IfDefine MOD_WSGI_WITH_PHP5> 
<IfModule !php5_module> 
Loadmodule php5_module '${MOD_WSGI_MODULES_DIRECTORY}/libphp5.so' 
</IfModule> 
AddHandler application/x-httpd-php .php 
</IfDefine> 
</IfModule> 


<IfVersion < 2.4> 
DefaultType text/plain 
</IfVersion> 

TypesConfig '/etc/mime.types' 

HostnameLookups Off 
MaxMemFree 64 
Timeout 60 
ListenBacklog 500 


<IfVersion >= 2.2.15> 
RequestReadTimeout header=15-30,MinRate=500 body=15,MinRate=500 
</IfVersion> 

LimitRequestBody 10485760 

<Directory /> 
    AllowOverride None 
    Order deny,allow 
    Deny from all 
</Directory> 

WSGIPythonHome '/usr' 

WSGIVerboseDebugging 'Off' 

<IfDefine !ONE_PROCESS> 
WSGIRestrictEmbedded On 
WSGISocketPrefix /home/xarxes_ub/python_code/Error_log//wsgi 
<IfDefine MOD_WSGI_MULTIPROCESS> 
WSGIDaemonProcess 161.116.80.72:8000 \ 
    display-name='(wsgi:161.116.80.72:8000:1027)' \ 
    home='/home/xarxes_ub/python_code' \ 
    processes=1 \ 
    threads=5 \ 
    maximum-requests=0 \ 
    python-path='' \ 
    python-eggs='/home/xarxes_ub/python_code/Error_log/python-eggs' \ 
    lang='es_ES.UTF-8' \ 
    locale='es_ES.UTF-8' \ 
    listen-backlog=100 \ 
    queue-timeout=45 \ 
    socket-timeout=60 \ 
    connect-timeout=15 \ 
    request-timeout=60 \ 
    inactivity-timeout=0 \ 
    deadlock-timeout=60 \ 
    graceful-timeout=15 \ 
    eviction-timeout=0 \ 
    shutdown-timeout=5 \ 
    send-buffer-size=0 \ 
    receive-buffer-size=0 \ 
    header-buffer-size=0 \ 
    response-buffer-size=0 \ 
    server-metrics=Off 
</IfDefine> 
<IfDefine !MOD_WSGI_MULTIPROCESS> 
WSGIDaemonProcess 161.116.80.72:8000 \ 
    display-name='(wsgi:161.116.80.72:8000:1027)' \ 
    home='/home/xarxes_ub/python_code' \ 
    threads=5 \ 
    maximum-requests=0 \ 
    python-path='' \ 
    python-eggs='/home/xarxes_ub/python_code/Error_log/python-eggs' \ 
    lang='es_ES.UTF-8' \ 
    locale='es_ES.UTF-8' \ 
    listen-backlog=100 \ 
    queue-timeout=45 \ 
    socket-timeout=60 \ 
    connect-timeout=15 \ 
    request-timeout=60 \ 
    inactivity-timeout=0 \ 
    deadlock-timeout=60 \ 
    graceful-timeout=15 \ 
    eviction-timeout=0 \ 
    shutdown-timeout=5 \ 
    send-buffer-size=0 \ 
    receive-buffer-size=0 \ 
    response-buffer-size=0 \ 
    server-metrics=Off 
</IfDefine> 
</IfDefine> 

WSGICallableObject 'application' 
WSGIPassAuthorization On 
WSGIMapHEADToGET Auto 

<IfDefine ONE_PROCESS> 
WSGIRestrictStdin Off 
<IfDefine MOD_WSGI_WITH_PYTHON_PATH> 
WSGIPythonPath '' 
</IfDefine> 
</IfDefine> 

<IfDefine MOD_WSGI_SERVER_METRICS> 
ExtendedStatus On 
</IfDefine> 

WSGIServerMetrics Off 

<IfDefine MOD_WSGI_SERVER_STATUS> 
<Location /server-status> 
    SetHandler server-status 
    Order deny,allow 
    Deny from all 
    Allow from localhost 
</Location> 
</IfDefine> 

<IfDefine MOD_WSGI_KEEP_ALIVE> 
KeepAlive On 
KeepAliveTimeout 0 
</IfDefine> 
<IfDefine !MOD_WSGI_KEEP_ALIVE> 
KeepAlive Off 
</IfDefine> 

<IfDefine MOD_WSGI_COMPRESS_RESPONSES> 
AddOutputFilterByType DEFLATE text/plain 
AddOutputFilterByType DEFLATE text/html 
AddOutputFilterByType DEFLATE text/xml 
AddOutputFilterByType DEFLATE text/css 
AddOutputFilterByType DEFLATE text/javascript 
AddOutputFilterByType DEFLATE application/xhtml+xml 
AddOutputFilterByType DEFLATE application/javascript 
</IfDefine> 

<IfDefine MOD_WSGI_ROTATE_LOGS> 
ErrorLog "|/usr/sbin/rotatelogs \ 
    /home/xarxes_ub/python_code/Error_log/error_log.%Y-%m-%d-%H_%M_%S 5M" 
</IfDefine> 
<IfDefine !MOD_WSGI_ROTATE_LOGS> 
ErrorLog "/home/xarxes_ub/python_code/Error_log/error_log" 
</IfDefine> 
LogLevel warn 

<IfDefine MOD_WSGI_ACCESS_LOG> 
<IfModule !log_config_module> 
LoadModule log_config_module ${MOD_WSGI_MODULES_DIRECTORY}/mod_log_config.so 
</IfModule> 
LogFormat "%h %l %u %t \"%r\" %>s %b" common 
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined 
LogFormat "undefined" custom 
<IfDefine MOD_WSGI_ROTATE_LOGS> 
CustomLog "|/usr/sbin/rotatelogs \ 
    /home/xarxes_ub/python_code/Error_log/access_log.%Y-%m-%d-%H_%M_%S 5M" common 
</IfDefine> 
<IfDefine !MOD_WSGI_ROTATE_LOGS> 
CustomLog "/home/xarxes_ub/python_code/Error_log/access_log" common 
</IfDefine> 
</IfDefine> 

<IfDefine MOD_WSGI_CHUNKED_REQUEST> 
WSGIChunkedRequest On 
</IfDefine> 

<IfDefine MOD_WSGI_WITH_PROXY_HEADERS> 
WSGITrustedProxyHeaders 
</IfDefine> 
<IfDefine MOD_WSGI_WITH_TRUSTED_PROXIES> 
WSGITrustedProxies 
</IfDefine> 

<IfDefine MOD_WSGI_WITH_HTTPS> 
<IfModule !ssl_module> 
LoadModule ssl_module ${MOD_WSGI_MODULES_DIRECTORY}/mod_ssl.so 
</IfModule> 
</IfDefine> 

<IfModule mpm_prefork_module> 
<IfDefine !ONE_PROCESS> 
ServerLimit 20 
StartServers 1 
MaxClients 20 
MinSpareServers 1 
MaxSpareServers 2 
</IfDefine> 
<IfDefine ONE_PROCESS> 
ServerLimit 1 
StartServers 1 
MaxClients 1 
MinSpareServers 1 
MaxSpareServers 1 
</IfDefine> 
MaxRequestsPerChild 0 
</IfModule> 

<IfModule mpm_worker_module> 
<IfDefine !ONE_PROCESS> 
ServerLimit 2 
ThreadLimit 10 
StartServers 1 
MaxClients 20 
MinSpareThreads 10 
MaxSpareThreads 10 
ThreadsPerChild 10 
</IfDefine> 
<IfDefine ONE_PROCESS> 
ServerLimit 1 
ThreadLimit 1 
StartServers 1 
MaxClients 1 
MinSpareThreads 1 
MaxSpareThreads 1 
ThreadsPerChild 1 
</IfDefine> 
MaxRequestsPerChild 0 
ThreadStackSize 262144 
</IfModule> 

<IfModule mpm_event_module> 
<IfDefine !ONE_PROCESS> 
ServerLimit 2 
ThreadLimit 10 
StartServers 1 
MaxClients 20 
MinSpareThreads 10 
MaxSpareThreads 10 
ThreadsPerChild 10 
</IfDefine> 
<IfDefine ONE_PROCESS> 
ServerLimit 1 
ThreadLimit 1 
StartServers 1 
MaxClients 1 
MinSpareThreads 1 
MaxSpareThreads 1 
ThreadsPerChild 1 
</IfDefine> 
MaxRequestsPerChild 0 
ThreadStackSize 262144 
</IfModule> 

<IfDefine !MOD_WSGI_VIRTUAL_HOST> 
<IfVersion < 2.4> 
NameVirtualHost *:8000 
</IfVersion> 
<VirtualHost _default_:8000> 
</VirtualHost> 
</IfDefine> 

<IfDefine MOD_WSGI_VIRTUAL_HOST> 

<IfVersion < 2.4> 
NameVirtualHost *:8000 
</IfVersion> 
<VirtualHost _default_:8000> 
<Location /> 
Order deny,allow 
Deny from all 
<IfDefine MOD_WSGI_ALLOW_LOCALHOST> 
Allow from localhost 
</IfDefine> 
</Location> 
</VirtualHost> 
<IfDefine !MOD_WSGI_HTTPS_ONLY> 
<VirtualHost *:8000> 
ServerName None 
<IfDefine MOD_WSGI_SERVER_ALIAS> 
ServerAlias None 
</IfDefine> 
</VirtualHost> 
<IfDefine MOD_WSGI_REDIRECT_WWW> 
<VirtualHost *:8000> 
ServerName unspecified 
Redirect permanent/http://None:8000/ 
</VirtualHost> 
</IfDefine> 
</IfDefine> 

<IfDefine MOD_WSGI_HTTPS_ONLY> 
<VirtualHost *:8000> 
ServerName None 
<IfDefine MOD_WSGI_SERVER_ALIAS> 
ServerAlias None 
</IfDefine> 
RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://None:None%{REQUEST_URI} 
</VirtualHost> 
<IfDefine MOD_WSGI_REDIRECT_WWW> 
<VirtualHost *:8000> 
ServerName unspecified 
RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://None:None%{REQUEST_URI} 
</VirtualHost> 
</IfDefine> 
</IfDefine> 

</IfDefine> 

<IfDefine MOD_WSGI_VIRTUAL_HOST> 

<IfDefine MOD_WSGI_WITH_HTTPS> 
<IfDefine MOD_WSGI_WITH_LISTENER_HOST> 
Listen 161.116.80.72:None 
</IfDefine> 
<IfDefine !MOD_WSGI_WITH_LISTENER_HOST> 
Listen None 
</IfDefine> 
<IfVersion < 2.4> 
NameVirtualHost *:None 
</IfVersion> 
<VirtualHost _default_:None> 
<Location /> 
Order deny,allow 
Deny from all 
<IfDefine MOD_WSGI_ALLOW_LOCALHOST> 
Allow from localhost 
</IfDefine> 
</Location> 
SSLEngine On 
SSLCertificateFile None 
SSLCertificateKeyFile None 
<IfDefine MOD_WSGI_VERIFY_CLIENT> 
SSLCACertificateFile None 
SSLVerifyClient none 
</IfDefine> 
<IfDefine MOD_WSGI_CERTIFICATE_CHAIN> 
SSLCertificateChainFile None 
</IfDefine> 
</VirtualHost> 
<VirtualHost *:None> 
ServerName None 
<IfDefine MOD_WSGI_SERVER_ALIAS> 
ServerAlias None 
</IfDefine> 
SSLEngine On 
SSLCertificateFile None 
SSLCertificateKeyFile None 
<IfDefine MOD_WSGI_VERIFY_CLIENT> 
SSLCACertificateFile None 
SSLVerifyClient none 
</IfDefine> 
<IfDefine MOD_WSGI_CERTIFICATE_CHAIN> 
SSLCertificateChainFile None 
</IfDefine> 
<IfDefine MOD_WSGI_HTTPS_ONLY> 
<IfDefine MOD_WSGI_HSTS_POLICY> 
Header set Strict-Transport-Security None 
</IfDefine> 
</IfDefine> 
<IfDefine MOD_WSGI_SSL_ENVIRONMENT> 
SSLOptions +StdEnvVars 
</IfDefine> 
</VirtualHost> 
<IfDefine MOD_WSGI_REDIRECT_WWW> 
<VirtualHost *:None> 
ServerName unspecified 
Redirect permanent/https://None:None/ 
SSLEngine On 
SSLCertificateFile None 
SSLCertificateKeyFile None 
<IfDefine MOD_WSGI_VERIFY_CLIENT> 
SSLCACertificateFile None 
SSLVerifyClient none 
</IfDefine> 
<IfDefine MOD_WSGI_CERTIFICATE_CHAIN> 
SSLCertificateChainFile None 
</IfDefine> 
</VirtualHost> 
</IfDefine> 
</IfDefine> 

</IfDefine> 

DocumentRoot '/home/xarxes_ub/python_code/Error_log/htdocs' 

<Directory '/home/xarxes_ub/python_code/Error_log/'> 
<Files handler.wsgi> 
    Order allow,deny 
    Allow from all 
</Files> 
</Directory> 

<Directory '/home/xarxes_ub/python_code/Error_log/htdocs/'> 
<IfDefine MOD_WSGI_DIRECTORY_INDEX> 
    DirectoryIndex None 
</IfDefine> 
<IfDefine MOD_WSGI_DIRECTORY_LISTING> 
    Options +Indexes 
</IfDefine> 
<IfDefine MOD_WSGI_CGI_SCRIPT> 
    Options +ExecCGI 
</IfDefine> 
<IfDefine MOD_WSGI_CGID_SCRIPT> 
    Options +ExecCGI 
</IfDefine> 
    RewriteEngine On 
    Include /home/xarxes_ub/python_code/Error_log//rewrite.conf 
<IfDefine !MOD_WSGI_STATIC_ONLY> 
    RewriteCond %{REQUEST_FILENAME} !-f 
<IfDefine MOD_WSGI_DIRECTORY_INDEX> 
    RewriteCond %{REQUEST_FILENAME} !-d 
</IfDefine> 
<IfDefine MOD_WSGI_SERVER_STATUS> 
    RewriteCond %{REQUEST_URI} !/server-status 
</IfDefine> 
    RewriteRule .* - [H=wsgi-handler] 
</IfDefine> 
    Order allow,deny 
    Allow from all 
</Directory> 

<IfDefine MOD_WSGI_ERROR_OVERRIDE> 
WSGIErrorOverride On 
</IfDefine> 

<IfDefine MOD_WSGI_HOST_ACCESS> 
<Location /> 
    WSGIAccessScript 'None' 
</Location> 
</IfDefine> 

<IfDefine MOD_WSGI_AUTH_USER> 
<Location /> 
    AuthType Basic 
    AuthName '161.116.80.72:8000' 
    AuthBasicProvider wsgi 
    WSGIAuthUserScript 'None' 
<IfDefine MOD_WSGI_AUTH_GROUP> 
    WSGIAuthGroupScript 'None' 
</IfDefine> 
<IfVersion < 2.4> 
    Require valid-user 
<IfDefine MOD_WSGI_AUTH_GROUP> 
    Require wsgi-group 'wsgi' 
</IfDefine> 
</IfVersion> 
<IfVersion >= 2.4> 
    <RequireAll> 
    Require valid-user 
<IfDefine MOD_WSGI_AUTH_GROUP> 
    Require wsgi-group 'wsgi' 
</IfDefine> 
    </RequireAll> 
</IfVersion> 
</Location> 
</IfDefine> 

<IfDefine !ONE_PROCESS> 
WSGIHandlerScript wsgi-handler '/home/xarxes_ub/python_code/Error_log//handler.wsgi' \ 
    process-group='161.116.80.72:8000' application-group=%{GLOBAL} 
WSGIImportScript '/home/xarxes_ub/python_code/Error_log//handler.wsgi' \ 
    process-group='161.116.80.72:8000' application-group=%{GLOBAL} 
</IfDefine> 

<IfDefine ONE_PROCESS> 
WSGIHandlerScript wsgi-handler '/home/xarxes_ub/python_code/Error_log//handler.wsgi' \ 
    process-group='%{GLOBAL}' application-group=%{GLOBAL} 
WSGIImportScript '/home/xarxes_ub/python_code/Error_log//handler.wsgi' \ 
    process-group='%{GLOBAL}' application-group=%{GLOBAL} 
</IfDefine> 


<IfDefine MOD_WSGI_VERIFY_CLIENT> 
<Location '/'> 
SSLVerifyClient require 
SSLVerifyDepth 1 
</Location> 
</IfDefine> 

Server version: Apache/2.2.22 (Ubuntu) 
Server built: Jul 24 2015 17:25:42 
Server's Module Magic Number: 20051115:30 
Server loaded: APR 1.4.6, APR-Util 1.3.12 
Compiled using: APR 1.4.6, APR-Util 1.3.12 
Architecture: 32-bit 
Server MPM:  Prefork 
    threaded:  no 
    forked:  yes (variable process count) 
Server compiled with.... 
-D APACHE_MPM_DIR="server/mpm/prefork" 
-D APR_HAS_SENDFILE 
-D APR_HAS_MMAP 
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) 
-D APR_USE_SYSVSEM_SERIALIZE 
-D APR_USE_PTHREAD_SERIALIZE 
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT 
-D APR_HAS_OTHER_CHILD 
-D AP_HAVE_RELIABLE_PIPED_LOGS 
-D DYNAMIC_MODULE_LIMIT=128 
-D HTTPD_ROOT="/etc/apache2" 
-D SUEXEC_BIN="/usr/lib/apache2/suexec" 
-D DEFAULT_PIDLOG="/var/run/apache2.pid" 
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status" 
-D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock" 
-D DEFAULT_ERRORLOG="logs/error_log" 
-D AP_TYPES_CONFIG_FILE="mime.types" 
-D SERVER_CONFIG_FILE="apache2.conf" 

をしたい人のための私のApacheの詳細ですのために作るために、以下のファイルを挿入

httpd.confファイルを生成し、サーバーのファイアウォールがサイトへの外部の要求(同じLANに接続されていない外部)をブロックしています 私のサーバーはUbuntu 12.04.5で動作していますLTS いずれにしてもsudo iptables -Lを実行し、

Chain INPUT (policy ACCEPT) 
target  prot opt source    destination   
ACCEPT  tcp -- anywhere    anywhere    tcp dpt:8000 /* Allow HTTP */ 
ACCEPT  tcp -- anywhere    anywhere    state NEW tcp dpt:8000 
ACCEPT  all -- anywhere    anywhere    ctstate RELATED,ESTABLISHED 
ACCEPT  tcp -- anywhere    anywhere    tcp dpt:ssh 
ACCEPT  tcp -- anywhere    anywhere    tcp dpt:8000 

Chain FORWARD (policy ACCEPT) 
target  prot opt source    destination   

Chain OUTPUT (policy ACCEPT) 
target  prot opt source    destination 

esults私は本当に私は、このような私は、ポートが閉じられたことが分かった。この1 http://www.canyouseeme.org/

としてウェブサイトをノックポートを使用してポート8000​​をチェックし

+0

を追加する必要がありました結果として、あなたは本当に '' --host'にホストIPを渡すべきではありませんオプションです。これは、完全修飾ホスト名の場合のみであり、実際にSSLを行う必要があるとき、または特定のインターフェースに限定するときにのみ有効です。 '' sys.stdout = sys.stderr''も必要ないので、 '' sys.stdout = sys.stderr''を実行しないでください。最後に、 '' --user www-data --group www-data''は、ポート8000​​で実行されている可能性が高いので、権限のないユーザとして実行する必要はありません。 –

+0

@GrahamDumpleton端末から次のコードを実行しようとしました 'mod_wsgiを発現するスタート・サーバconfigure.wsgi --server-ルート/ホーム/ xarxes_ub/python_code/ERROR_LOG /' 私はまだ同じ問題を取得し 私もMenuUB2から ' を以下のようになるためにconfigure.wsgi編集アプリケーションとしてアプリケーションをインポートする #import sys #sys.stdout = sys.stderr' –

答えて

0

得ることができます任意の助けに感謝します。開いている唯一のポートはポート80と22です。私が作業しているサーバーには、アクセスできないファイアウォールがあります。

私はポート80上のhttpd.confファイルを変更し、開始するために、以下の行

WSGIScriptAlias /submitFrame /home/xarxes_ub/python_code/configure.wsgi 
WSGIDaemonProcess MenuUB2 threads=5 

<Directory /home/xarxes_ub/python_code> 
      # WSGIScriptReloading On 
     WSGIProcessGroup MenuUB2 
      WSGIApplicationGroup %{GLOBAL} 
      Order deny,allow 
      Allow from all 
</Directory> 
+0

これはデフォルトであるため、 '' WSGIScriptReloading On''は必要ありません。デフォルトでも '' user = www-data group = www-data''は必要ありません。 –

+0

よろしくお願いします。 新しい情報で回答を変更します –

関連する問題