zoukankan      html  css  js  c++  java
  • 使域名跳转至SpringBoot设置的content-path路径

      在使用SpringBoot开发的一个系统时设置了content-path,后来临时需要使域名能够跳转到一个指定的路径上,但是直接访问域名时打开是404,必须依照配置的RequestMapping打开才行。举个例子,某个网页的路径是 http://vpsname.com/webpage/index,配置后可以通过打开 http://vpsname.com/ 跳转到 http://vpsname.com/webpage/index 。在尝试一些配置之后放弃了对SpringBoot的配置,下面简述一下我的解决方案。

      方法很简单,就是通过nginx,根据访问的路径进行映射,因为nginx和springboot都运行在同一台服务器上,所以只需要映射到本地+端口即可。对于域名的访问指向本地的index.html,再html页面内设置自动跳转即可。

            location /webpage/ {
                proxy_pass http://localhost:8080/webpage/;
            }
    
            location / {
                root   html;
                index  index.html index.htm;
            }

      通过上面的nginx配置后,打开 http://vpsname.com/ 即可跳转至 http://vpsname.com/webpage/index 页面。

      目前暂时没有更好的方法,如果有更好的方法或建议,欢迎指正!

    * 以上链接仅做举例使用。

  • 相关阅读:
    test
    c# cook book -Linq 关于Object的比较
    关于UnitOfWork
    autofac学习
    webapi 开启跨域支持
    httpclient通过post提交到webapi
    jQuery之元素查找
    jQuery之过滤元素
    jQuery之回到顶部
    jQuery之_元素滚动
  • 原文地址:https://www.cnblogs.com/shenyuanfeng/p/12919701.html
Copyright © 2011-2022 走看看