-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
针对portal添加基于path的反向代理支持 #2754
针对portal添加基于path的反向代理支持 #2754
Conversation
在app.js中定义了path常量和filter,同时在AppUtil服务中定义了获取path的方法 var appUtil = angular.module('app.util', ['toastr', 'ngCookies', 'pascalprecht.translate'])
.constant("prefixLocation", "这里为反向代理path") // 前缀路径
.filter('prefixPath',['prefixLocation', function(prefixLocation) { // 前缀路径过滤器
return function(text) {
return prefixLocation + text;
}
}]) 同时修改了js和html中对资源的引用路径,并进行了测试,可以支持基于path的反向代理 |
Codecov Report
@@ Coverage Diff @@
## master #2754 +/- ##
============================================
- Coverage 50.48% 50.45% -0.03%
- Complexity 2084 2085 +1
============================================
Files 413 414 +1
Lines 12666 12668 +2
Branches 1294 1294
============================================
- Hits 6394 6392 -2
- Misses 5819 5822 +3
- Partials 453 454 +1
Continue to review full report at Codecov.
|
这个功能挺不错的,希望能以配置参数的方式传入 |
这个功能点很不错,👍 看代码,现在如果要配置反向代理路径的话,是需要修改app.js然后重新打包? |
嗯,目前确实是需要修改app.js并重新打包,我抽空改一下 |
@nobodyiam
然后重启一下portal即可生效,不用再打包了 |
@@ -271,7 +271,7 @@ protected void configure(HttpSecurity http) throws Exception { | |||
http.csrf().disable(); | |||
http.headers().frameOptions().sameOrigin(); | |||
http.authorizeRequests() | |||
.antMatchers("/prometheus/**","/metrics/**","/openapi/**", "/vendor/**", "/styles/**", "/scripts/**", "/views/**", "/img/**", "/i18n/**").permitAll() | |||
.antMatchers("/prometheus/**","/metrics/**","/openapi/**", "/vendor/**", "/styles/**", "/scripts/**", "/views/**", "/img/**", "/i18n/**", "/prefixPath").permitAll() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is another place to change, just search i18n
in this program
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
另外一个地方已修改
@nobodyiam |
@RestController | ||
public class PrefixPathController { | ||
|
||
@Value("${prefixPath: }") private String prefixPath; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Value("${prefixPath: }")
will cause the default prefixPath to be " "
instead of ""
.
Though it is still working(I guess the browser does some trick), I would suggest we change it as follows:
@Value("${prefixPath:}")
private String prefixPath;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, it works as expected. And a FAQ is added for this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已按照建议进行修改
@nobodyiam 我拉下最新的代码,编译并且使用-DprefixPath=/apollo -Dserver.servlet.context-path=/apollo,可以访问,但是出现了以下两个问题
2.在控制面板点击用户再点退出,会自动跳到根路径,报404 |
问题解决,启动时添加-Dapollo_profile=github,auth -DprefixPath=/apollo -Dserver.servlet.context-path=/apollo参数 我是用Idea编译的,-Dapollo_profile=github,auth必须添加,否则会出现#2142 Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.这样的报错 |
use -Dprefix.path=/apollo -Dserver.servlet.context-path=/apollo can work |
fixed 域名配置问题 #1154