【问题标题】:get springboot to route to your subdomain as opposed to localhost让 spring boot 路由到您的子域,而不是 localhost
【发布时间】:2020-07-15 20:07:16
【问题描述】:

假设我有一个域“example.com”。现在,使用 caddy,我已将 example.com 配置为在 localhost 8080 上运行的 springboot 应用程序的代理。如何正确转到应用程序内的其他路由?例如,如果我转到https://example.com/user,则 url 将是:example.com/user。但是如果我从 springboot 应用程序中从那里路由到 /login (可以说在控制器中的用户路由末尾使用 return new RedirectView("/login") ),它会将我重定向到 http:serverIpAdress:8080 /登录。我怎样才能让它路由到https://example.com/login

【问题讨论】:

    标签: java spring-boot model-view-controller thymeleaf caddy


    【解决方案1】:

    这不是 Spring 的问题; Caddy 需要正确配置如下:

    subdomain {                                                                       
        proxy / ipAddress:port { 
            transparent                                                                   
        }                                                                                         
    }
    

    1) 注意 caddyfile 中的间距。我最初尝试过但它没有用,我相信原因是因为我创建了这样的文件:subdomain { 代理 / ipAddress:port { 透明 }} 2)它确实起作用了一点点混乱,从我在互联网上看到的许多地方看来,它们似乎从 api 中删除了透明

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-15
      • 1970-01-01
      • 2020-01-04
      • 1970-01-01
      相关资源
      最近更新 更多