httpd.conf:
<VirtualHost *:88>
ServerName <myserver.com>
WSGIDaemonProcess feedlerbot user=apache group=apache threads=5
WSGIScriptAlias / /var/www/feedler/feedler_bot/bot.wsgi
<Directory /var/www/feedler/feedler_bot/>
WSGIProcessGroup feedlerbot
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
bot.wsgi:
#!/usr/bin/env python
import sys
# activate virtualenv
activate_this = '/var/www/feedler/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
# path to flask app
sys.path.insert(0, '/var/www/feedler/feedler_bot')
from bot import app as application
bot.py:
app = flask.Flask(__name__)
# Empty webserver index, return nothing, just http 200
@app.route('/', methods=['GET', 'HEAD'])
def index():
return 'Feedler Bot using webhooks works fine!'
# Process webhook calls
@app.route(WebhooksSetting.WEBHOOK_URL_PATH, methods=['POST'])
def webhook():
if flask.request.headers.get('content-type') == 'application/json':
json_string = flask.request.get_data().decode('utf-8')
update = telebot.types.Update.de_json(json_string)
bot.process_new_updates([update])
return ''
else:
flask.abort(403)
"""Start of the bot logic"""
<bot_logic>
"""End of the bot logic"""
# Remove webhook, it fails sometimes the set if there is a previous webhook
bot.remove_webhook()
time.sleep(1)
# Set webhook
bot.set_webhook(url=WebhooksSetting.WEBHOOK_URL_BASE + WebhooksSetting.WEBHOOK_URL_PATH,
certificate=open(WebhooksSetting.WEBHOOK_SSL_CERT, 'r'))
# Start flask server
if __name__ == '__main__':
app.run(host=WebhooksSetting.WEBHOOK_LISTEN,
port=WebhooksSetting.WEBHOOK_PORT,
ssl_context=(WebhooksSetting.WEBHOOK_SSL_CERT, WebhooksSetting.WEBHOOK_SSL_PRIV),
debug=True)
端口88已打开,但是尝试在浏览器中打开时,https://myserver.com:88/-连接被拒绝。日志/ etc / httpd / logs / error_log为空。我哪里错了?此外,另一个电报漫游器完全可以在同一台服务器上的相同方案下工作,但只能在端口8443上工作。