在单个域上使用两个不同的框架(Oracle Weblogic / Django)

Using two different frameworks on a single domain (Oracle Weblogic / Django)

假设我的公司在 https://example.com 有一个站点,它由旧版本的 Oracle Weblogic 提供支持。公司希望最终将站点转换为 Django 框架,但希望逐步完成。

具体来说,它希望在旧框架上维护原始站点,但希望设置一个子文件夹,如 https://example.com/newurl/ (or, alternatively, a subdomain like https://newurl.example.com),其中将包含一个具有新功能等的 Django 项目,以及这个新框架中的任何子目录url 同样只包含 Django 应用程序。

我的问题是,是否可以通过这种方式将两个框架包含在同一个域中?如果可以,如何使用 Apache 来实现?谢谢

是的,当然有可能。试用reverse proxy软件,例如:

reverse proxy is a type of proxy server that retrieves resources on behalf of a client from one or more servers. These resources are then returned to the client, appearing as if they originated from the proxy server itself.[1] Unlike a forward proxy, which is an intermediary for its associated clients to contact any server, a reverse proxy is an intermediary for its associated servers to be contacted by any client. In other words, a proxy acts on behalf of the client(s), while a reverse-proxy acts on behalf of the server(s). ()

Nginx 反向代理示例配置

server {
  listen 80;

  server_name example.com;

  location ~ /newurl {
    proxy_pass http://django-server;
  }

  location ~ /oldurl {
    proxy_pass http://oracle-weblogic-server;
  }
}

HaProxy 反向代理示例配置

frontend http_frontend
bind *:80
mode http
option httpclose
acl is_newurl hdr_end(host) -i newurl
use_backend django if is_newurl
acl is_oldurl hdr_end(host) -i oldurl
use_backend oracle if is_oldurl

backend django
mode http
cookie SERVERID insert indirect nocache
server django django-server:80 check cookie django

backend oracle
mode http
cookie SERVERID insert indirect nocache
server oracle oracle-weblogic-server:80 check cookie oracle