2017-12-20 16 views
0

나는 http 요청 요청 데이터를 json 형식으로 처리하기 위해 Flask로 엔드 포인트를 작성했다. apache2에 배포하려고 할 때 게시 요청에 404 오류가 발생했습니다 : "요청한 URL/bridge가이 서버에서 발견되지 않았습니다". 나는 파이썬 3.5.2, 아파치 2.4, OpenSSL/1.0.2g, 우분투 16.04, 파이썬 3.5.1+를 위해 컴파일 된 mod_wsgi4.3.0을 사용하고있다.404 apache2의 플라스크 애플리케이션에 대한 url 오류를 찾을 수 없음

아무도 모른다. 아파치는/var/www를 볼 수 없지만 그 이유는 무엇입니까? SSL 구성에 문제가 있습니까? 내가 /etc/apache2/sites-enabled/bridge.conf에서 /var/www/bridge/bridge.wsgi

#!/usr/bin/python3 
import sys 

sys.path.insert(0,'/var/www/bridge') 

from bridge import app as application 

의 conf 파일에

(HTTPS는의 webiste 작동)

<VirtualHost *:443> 
ServerName www.newocto.org 

WSGIDaemonProcess bridge user=www-data group=www-data threads=5 home=/var/www/bridge/ 
WSGIScriptAlias /bridge /var/www/bridge/bridge.wsgi 

<Directory /var/www/bridge> 
    WSGIProcessGroup bridge 
    WSGIApplicationGroup %{GLOBAL} 


    Require all granted 
</Directory> 

내 000-default.conf 파일은 다음과 같다 :

<VirtualHost *:443> 
# The ServerName directive sets the request scheme, hostname and port that 
# the server uses to identify itself. This is used when creating 
# redirection URLs. In the context of virtual hosts, the ServerName 
# specifies what hostname must appear in the request's Host: header to 
# match this virtual host. For the default virtual host (this file) this 
# value is not decisive as it is used as a last resort host regardless. 
# However, you must set it for any further virtual host explicitly. 
ServerName www.newocto.org 
DocumentRoot /var/www/html 

SSLEngine on 
SSLCertificateFile /etc/ssl/certs/newocto_org.crt 
SSLCertificateKeyFile /etc/ssl/private/newocto.key 
SSLCertificateChainFile /etc/ssl/certs/COMODORSAAddTrustCA.crt 
RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L] 

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn, 
# error, crit, alert, emerg. 
# It is also possible to configure the loglevel for particular 
# modules, e.g. 
#LogLevel info ssl:warn 

ErrorLog ${APACHE_LOG_DIR}/error.log 
CustomLog ${APACHE_LOG_DIR}/access.log combined 

# For most configuration files from conf-available/, which are 
# enabled or disabled at a global level, it is possible to 
# include a line for only one particular virtual host. For example the 
# following line enables the CGI configuration for this host only 
# after it has been globally disabled with "a2disconf". 
#Include conf-available/serve-cgi-bin.conf 
</VirtualHost> 

<VirtualHost *:80> 
ServerName newocto.org/ 
Redirect/https://newocto.org/ 
</VirtualHost> 

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet 

그리고 당신은 같은 ServerName 및 포트에 대한 두 VirtualHost 섹션을 가질 수 없습니다 /var/www/bridge/bridge.py에서 내 플라스크 코드가

#!/usr/bin/python3 

from flask import Flask 


app = Flask(__name__) 

@app.route('/', methods =['POST']) 
def deliver(): 
    from flask import request 
    raw=request.get_json(force=True) 
    return raw 

import mysql.connector 
dbconn= mysql.connector.connect(host='xxxx',port='3306',database='xx',user='root',password='xxx') 
cursor=dbconn.cursor() 
query="""insert into bridge_test2 (email) values ('{}')""".format(raw) 
cursor.execute(query) 
dbconn.commit() 
dbconn.close() 


if __name__ == '__main__': 
    app.run() 



#file permissions are like this: 
#4 -rwxr-xr-x 1 root www-data 537 Dec 20 13:46 bridge.py 
#4 -rwxr-xr-x 1 root www-data 117 Dec 20 14:10 bridge.wsgi 

답변

0

, 그것은 첫 번째를 사용합니다 본다.

VirtualHost의 내용을 bridge.confServerName 및 포트 000-default.conf의 내용으로 복사하십시오.

+0

감사합니다.이 "url not found"문제가 해결되었습니다. 이제 wsgi 오류가 발생했습니다. 액세스 로그에서 아파치가 POST 요청을 GET 요청으로 리다이렉트하는 것을 본다 : [21/Dec/2017 : 18 : 07 : 05 +0300] "POST/bridge HTTP/1.1"301 3830 "-" "-"[21/Dec/2017 : 18 : 07 : 05 +0300] "GET/bridge/HTTP/1.1"500 860 "-" "-"왜? "mod_wsgi (pid = 28907) : 요청 용 양동 여단을 얻을 수 없습니다."고유 한 conf에서 포트 80의 'Rewrite'및 Virtualhost로 시작하는 모든 행을 제거했습니다. 오류 로그는 "부분 결과가 유효하지만 처리가 불완전합니다. 파일,하지만 도움이되지 않았다. 어떤 생각? – dogacan

+0

현재 구성으로 새 질문을 만듭니다. –

+0

여기에 있습니다 : https://stackoverflow.com/questions/47939148/wsgi-error-unable-to-get-bucket-brigade-for-request-apache2-redirects-post-to – dogacan