我最近在 VPS 上设置了 Seatable Enterprise。 Seatable 作为包含 nginx 的 Docker 映像提供。我使用 Let's Encrypt 生成密钥/证书并配置 SSL 访问。 我现在尝试在 Web 服务器旁边运行 python Tornado 服务器,但我无法访问我的网页...... 这是 Tornado 的
server.py
文件的最小版本,用于查看配置(唯一值得注意的是端口:8443 和映射)
#! /usr/bin/python
import os.path
import tornado.httpserver
import tornado.websocket
import tornado.ioloop
import tornado.web
import asyncio
from tornado_request_mapping import request_mapping, Route
####### Serveur Tornado #######
PORT = 8443
settings = dict(
template_path = os.path.join(os.path.dirname(__file__), "templates"),
static_path = os.path.join(os.path.dirname(__file__), "static")
)
@request_mapping("/products")
class PainMainHandler(tornado.web.RequestHandler):
@request_mapping("/order.html")
def get(self):
print("[HTTP](MainHandler) User Connected.")
self.render("products/order.html")
@request_mapping("/ws")
class PainWSHandler(tornado.websocket.WebSocketHandler):
def open(self):
print('[WS] Connection was opened.')
async def on_message(self, message):
print('[WS] Incoming message:', message)
def on_close(self):
print('[WS] Connection was closed.')
if __name__ == "__main__":
try:
application = tornado.web.Application(**settings)
route = Route(application)
route.register(PainMainHandler)
route.register(PainWSHandler)
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(PORT)
main_loop = tornado.ioloop.IOLoop.instance()
print("Tornado Server started")
main_loop.start()
except:
print("Exception triggered - Tornado Server stopped.")
在本地尝试,一切正常(我使用地址http://localhost:8443/products/order.html看到我的
order.html
页面的内容)。
我将这些文件上传到我的 VPS 上,以便在 nginx 服务器旁边运行龙卷风的网络服务器,但无论我尝试什么,我仍然收到错误(400 或 414 或 512 或来自 Seatable 的自定义 404 页面)。这是
nginx.conf
文件的一部分:
server {
if ($host = myserver.vps.ovh.net) {
return 301 https://$host$request_uri;
}
listen 80;
server_name vps-25355c52.vps.ovh.net;
return 404;
}
server {
server_name myserver.vps.ovh.net;
listen 443 ssl;
ssl_certificate /shared/ssl/fullchain.pem;
ssl_certificate_key /shared/ssl/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
# for letsencrypt
location /.well-known/acme-challenge/ {
alias /var/www/challenges/;
try_files $uri =404;
}
proxy_set_header X-Forwarded-For $remote_addr;
location / {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
return 204;
}
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_read_timeout 1200s;
# used for view/edit office file via Office Online Server
client_max_body_size 0;
access_log /opt/nginx-logs/dtable-web.access.log;
error_log /opt/nginx-logs/dtable-web.error.log;
}
我尝试添加新的
server
配置,例如
server {
listen 8443;
server_name myserver.vps.ovh.net;
location /pain {
proxy_pass http://127.0.0.1:8443/products/order.html;
proxy_redirect off;
access_log /opt/nginx-logs/pain.access.log;
error_log /opt/nginx-logs/pain.error.log;
}
}
与
proxy_pass http://127.0.0.1:8443/products/order.html;
或 proxy_pass http://127.0.0.1:8443/;
我还尝试在第二个 /products
配置中添加一个新位置 server
,并使用与之前相同的两个 proxy_pass
变体,但没有任何效果。我确定我错过了一些东西,你有什么想法吗?
非常感谢
您可以在 Seatable 论坛中提问,https://forum.seatable.io/