apache2에 배치 된 Flask 앱으로 게시물 요청을 처리하고 싶지만 의도하지 않은 리다이렉션이 있습니다. 또한 요청 본문을 잃어 버립니다. 웹 응용 프로그램을 사용하여 게시물 요청을 실행하고 액세스 로그에 57.39.118.158 - [22/Dec/2017 : 11 : 44 : 32 +0300] "POST/bridge HTTP/1.1"301 3830 "-" " - 57.39.118.158 - - [22/Dec/2017 : 11 : 44 : 32 +0300] "GET/bridge/HTTP/1.1"500 860 "-" "-"오류 로그 : "[Fri Dec 22 11 : 44 : 51.864122 2017] [wsgi : 오류] [pid 28906 : tid 139849921148672] (70008) 부분 결과가 유효하지만 처리가 완료되지 않았습니다. [client 57.39.118.158:35172] mod_wsgi (pid = 28906) : 버킷을 가져올 수 없습니다. 요청한 여단 " 전에 "URL을 찾을 수 없음"이라는 문제가 404 url not found error for flask app on apache2에서 해결되었습니다. 내가 파이썬 3.5.2를 사용하고 있습니다wsgi 오류 : bucket 여단을 요청에 사용할 수 없습니다. & apache2는 게시를 리디렉션합니까?
, 아파치 2.4, OpenSSL을/1.0.2g, 우분투는 16.04, mod_wsgi4.3.0 내가 고유의 conf 파일을 사용하고이처럼이
파이썬 3.5.1+ 컴파일 : /var/www/bridge/bridge.wsgi에서
<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 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
# 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
WSGIDaemonProcess bridge user=dogacandu group=dogacandu 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>
# 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>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
파일 /var/www/bridge/bridge.py에서
#!/usr/bin/python3
import sys
sys.path.insert(0,'/var/www/bridge')
from bridge import app as application
파일
입니다 0#!/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)
import mysql.connector
dbconn= mysql.connector.connect(host='xx.20.xxx.245',port='3306',database='xxa',user='root',password='Jxxxo')
cursor=dbconn.cursor()
query1="""insert into bridge_test2 (email) values ('blah')"""
query2="""insert into bridge_test2 (email) values ('{}')""".format(raw)
cursor.execute(query1)
dbconn.commit()
cursor.execute(query2)
dbconn.commit()
dbconn.close()
return 'ok'
if __name__ == '__main__':
app.run()
파일 권한 :
4 -rwxr-xr-x 1 root dogacandu 654 Dec 21 17:31 bridge.py
4 -rwxr-xr-x 1 root dogacandu 117 Dec 20 18:26 bridge.wsgi
dogacandu은 sudo는 privilage와 사용자입니다. 활성화 개조는 다음과 같습니다
access_compat.load authn_core.load authz_user.load cgid.load dir.load mime.load negotiation.load socache_shmcb.load status.load alias.conf authn_file.load autoindex.conf deflate.conf ENV. load mpm_event.conf rewrite.load ssl.conf wsgi.conf alias.load authz_core.load autoindex.load deflate.load filter.load mpm_event.load setenvif.conf ssl.load wsgi.load auth_basic.load authz_host.load cgid. conf의 dir.conf mime.conf negotiation.conf setenvif.load status.conf
재로드 문제가 발생할 수 있습니다? 어떤 제안?
내 처리기를 마운트 지점에서 옮기면 작동합니다. :) 고마워! – dogacan