【问题标题】:vhost config in cyberpanel is not working网络面板中的虚拟主机配置不起作用
【发布时间】:2022-08-04 15:03:39
【问题描述】:

有 vhost 配置,它应该是烧瓶应用程序的反向代理,并且不工作。下面是虚拟主机配置。 Flask 应用程序正在端口 5000 上运行。

在上下文和外部都添加了重写,即使那样它也不起作用。下面的配置总是给出错误 500。

vhDomain                  $VH_NAME
vhAliases                 www.$VH_NAME
enableGzip                1
enableIpGeo               1

index  {
  useServer               0
  indexFiles              index.php, index.html
}

errorlog $VH_ROOT/logs/$VH_NAME.error_log {
  useServer               0
  logLevel                WARN
  rollingSize             10M
}

accesslog $VH_ROOT/logs/$VH_NAME.access_log {
  useServer               0
  logFormat               \"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"\"
  logHeaders              5
  rollingSize             10M
  keepDays                10  
  compressArchive         1
}

extprocessor pythonflask1709 {
  type                    proxy
  address                 127.0.0.1:5000
  maxConns                200
  pcKeepAliveTimeout      60
  initTimeout             20
  retryTimeout            0
  respBuffer              0
}

scripthandler {
  add proxy:pythonflask1709 html
}

module cache {
 storagePath /usr/local/lsws/cachedata/$VH_NAME
}

rewrite  {
  enable 1
  autoLoadHtaccess 1
  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  REWRITERULE ^(.*)$ HTTPS://127.0.0.1:5000/$1 [P]
}

context / {
  type                    proxy
  handler                 pythonflask1709
  addDefaultCharset       off
 
  rewrite  {
    enable 1
    autoLoadHtaccess 1
    RewriteEngine On
    RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    REWRITERULE ^(.*)$ HTTP://127.0.0.1:5000/$1 [P]
  }
}

    标签: vhosts cyber-panel


    【解决方案1】:

    对于反向代理,您创建了一个名为 pythonflask1709 的 Web 服务器外部应用程序,这很好。下一步是设置上下文、重写规则或脚本处理程序。

    上下文方法

    context / {
      type                    proxy
      handler                 demo
      addDefaultCharset       off
    }
    

    重写方法

    REWRITERULE ^(.*)$ HTTP://pythonflask1709/$1 [P,L,E=PROXY-HOST:WWW.EXAMPLE.COM]
    

    如您所见,请在规则中使用网络服务器名称pythonflask1709 而不是 127.0.0.1:5000,也请用您的真实域名替换 WWW.EXAMPLE.COM。

    两者都应该有效,但请不要同时应用这两种方法。

    另一种解决方案是直接运行WSGI APP,无需代理。 更多,https://openlitespeed.org/kb/python-wsgi-applications/#Set_up_Flask_with_a_Virtual_Environment

    【讨论】:

      猜你喜欢
      • 2017-07-23
      • 2015-02-08
      • 1970-01-01
      • 2020-02-15
      • 1970-01-01
      • 1970-01-01
      • 2015-10-13
      • 2016-09-29
      • 2018-05-09
      相关资源
      最近更新 更多