mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-07 23:30:26 +08:00
静态分发增加例外URL、限制URL、排除隐藏文件等选项
This commit is contained in:
@@ -347,7 +347,7 @@ func (this *CreateAction) RunPost(params struct {
|
|||||||
var rootJSON []byte
|
var rootJSON []byte
|
||||||
var err error
|
var err error
|
||||||
if len(params.WebRoot) > 0 {
|
if len(params.WebRoot) > 0 {
|
||||||
var rootConfig = &serverconfigs.HTTPRootConfig{}
|
var rootConfig = serverconfigs.NewHTTPRootConfig()
|
||||||
rootConfig.IsOn = true
|
rootConfig.IsOn = true
|
||||||
rootConfig.Dir = params.WebRoot
|
rootConfig.Dir = params.WebRoot
|
||||||
rootConfig.Indexes = []string{"index.html", "index.htm"}
|
rootConfig.Indexes = []string{"index.html", "index.htm"}
|
||||||
|
|||||||
@@ -1,23 +1,34 @@
|
|||||||
Vue.component("http-web-root-box", {
|
Vue.component("http-web-root-box", {
|
||||||
props: ["v-root-config", "v-is-location", "v-is-group"],
|
props: ["v-root-config", "v-is-location", "v-is-group"],
|
||||||
data: function () {
|
data: function () {
|
||||||
let rootConfig = this.vRootConfig
|
let config = this.vRootConfig
|
||||||
if (rootConfig == null) {
|
if (config == null) {
|
||||||
rootConfig = {
|
config = {
|
||||||
isPrior: false,
|
isPrior: false,
|
||||||
isOn: false,
|
isOn: false,
|
||||||
dir: "",
|
dir: "",
|
||||||
indexes: [],
|
indexes: [],
|
||||||
stripPrefix: "",
|
stripPrefix: "",
|
||||||
decodePath: false,
|
decodePath: false,
|
||||||
isBreak: false
|
isBreak: false,
|
||||||
|
exceptHiddenFiles: true,
|
||||||
|
onlyURLPatterns: [],
|
||||||
|
exceptURLPatterns: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rootConfig.indexes == null) {
|
if (config.indexes == null) {
|
||||||
rootConfig.indexes = []
|
config.indexes = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.onlyURLPatterns == null) {
|
||||||
|
config.onlyURLPatterns = []
|
||||||
|
}
|
||||||
|
if (config.exceptURLPatterns == null) {
|
||||||
|
config.exceptURLPatterns = []
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
rootConfig: rootConfig,
|
config: config,
|
||||||
advancedVisible: false
|
advancedVisible: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -30,27 +41,27 @@ Vue.component("http-web-root-box", {
|
|||||||
teaweb.popup("/servers/server/settings/web/createIndex", {
|
teaweb.popup("/servers/server/settings/web/createIndex", {
|
||||||
height: "10em",
|
height: "10em",
|
||||||
callback: function (resp) {
|
callback: function (resp) {
|
||||||
that.rootConfig.indexes.push(resp.data.index)
|
that.config.indexes.push(resp.data.index)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
removeIndex: function (i) {
|
removeIndex: function (i) {
|
||||||
this.rootConfig.indexes.$remove(i)
|
this.config.indexes.$remove(i)
|
||||||
},
|
},
|
||||||
isOn: function () {
|
isOn: function () {
|
||||||
return ((!this.vIsLocation && !this.vIsGroup) || this.rootConfig.isPrior) && this.rootConfig.isOn
|
return ((!this.vIsLocation && !this.vIsGroup) || this.config.isPrior) && this.config.isOn
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `<div>
|
template: `<div>
|
||||||
<input type="hidden" name="rootJSON" :value="JSON.stringify(rootConfig)"/>
|
<input type="hidden" name="rootJSON" :value="JSON.stringify(config)"/>
|
||||||
<table class="ui table selectable definition">
|
<table class="ui table selectable definition">
|
||||||
<prior-checkbox :v-config="rootConfig" v-if="vIsLocation || vIsGroup"></prior-checkbox>
|
<prior-checkbox :v-config="config" v-if="vIsLocation || vIsGroup"></prior-checkbox>
|
||||||
<tbody v-show="(!vIsLocation && !vIsGroup) || rootConfig.isPrior">
|
<tbody v-show="(!vIsLocation && !vIsGroup) || config.isPrior">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="title">启用静态资源分发</td>
|
<td class="title">启用静态资源分发</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input type="checkbox" v-model="rootConfig.isOn"/>
|
<input type="checkbox" v-model="config.isOn"/>
|
||||||
<label></label>
|
<label></label>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -60,7 +71,7 @@ Vue.component("http-web-root-box", {
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="title">静态资源根目录</td>
|
<td class="title">静态资源根目录</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="root" v-model="rootConfig.dir" ref="focus" placeholder="类似于 /home/www"/>
|
<input type="text" name="root" v-model="config.dir" ref="focus" placeholder="类似于 /home/www"/>
|
||||||
<p class="comment">可以访问此根目录下的静态资源。</p>
|
<p class="comment">可以访问此根目录下的静态资源。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -72,8 +83,8 @@ Vue.component("http-web-root-box", {
|
|||||||
<td>首页文件</td>
|
<td>首页文件</td>
|
||||||
<td>
|
<td>
|
||||||
<!-- TODO 支持排序 -->
|
<!-- TODO 支持排序 -->
|
||||||
<div v-if="rootConfig.indexes.length > 0">
|
<div v-if="config.indexes.length > 0">
|
||||||
<div v-for="(index, i) in rootConfig.indexes" class="ui label tiny">
|
<div v-for="(index, i) in config.indexes" class="ui label small basic">
|
||||||
{{index}} <a href="" title="删除" @click.prevent="removeIndex(i)"><i class="icon remove"></i></a>
|
{{index}} <a href="" title="删除" @click.prevent="removeIndex(i)"><i class="icon remove"></i></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui divider"></div>
|
<div class="ui divider"></div>
|
||||||
@@ -82,10 +93,31 @@ Vue.component("http-web-root-box", {
|
|||||||
<p class="comment">在URL中只有目录没有文件名时默认查找的首页文件。</p>
|
<p class="comment">在URL中只有目录没有文件名时默认查找的首页文件。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>例外URL</td>
|
||||||
|
<td>
|
||||||
|
<url-patterns-box v-model="config.exceptURLPatterns"></url-patterns-box>
|
||||||
|
<p class="comment">如果填写了例外URL,表示不支持通过这些URL访问。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>限制URL</td>
|
||||||
|
<td>
|
||||||
|
<url-patterns-box v-model="config.onlyURLPatterns"></url-patterns-box>
|
||||||
|
<p class="comment">如果填写了限制URL,表示仅支持通过这些URL访问。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>排除隐藏文件</td>
|
||||||
|
<td>
|
||||||
|
<checkbox v-model="config.exceptHiddenFiles"></checkbox>
|
||||||
|
<p class="comment">排除以点(.)符号开头的隐藏目录或文件,比如<code-label>/.git/logs/HEAD</code-label></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>去除URL前缀</td>
|
<td>去除URL前缀</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" v-model="rootConfig.stripPrefix" placeholder="/PREFIX"/>
|
<input type="text" v-model="config.stripPrefix" placeholder="/PREFIX"/>
|
||||||
<p class="comment">可以把请求的路径部分前缀去除后再查找文件,比如把 <span class="ui label tiny">/web/app/index.html</span> 去除前缀 <span class="ui label tiny">/web</span> 后就变成 <span class="ui label tiny">/app/index.html</span>。 </p>
|
<p class="comment">可以把请求的路径部分前缀去除后再查找文件,比如把 <span class="ui label tiny">/web/app/index.html</span> 去除前缀 <span class="ui label tiny">/web</span> 后就变成 <span class="ui label tiny">/app/index.html</span>。 </p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -93,17 +125,17 @@ Vue.component("http-web-root-box", {
|
|||||||
<td>路径解码</td>
|
<td>路径解码</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input type="checkbox" v-model="rootConfig.decodePath"/>
|
<input type="checkbox" v-model="config.decodePath"/>
|
||||||
<label></label>
|
<label></label>
|
||||||
</div>
|
</div>
|
||||||
<p class="comment">是否对请求路径进行URL解码,比如把 <span class="ui label tiny">/Web+App+Browser.html</span> 解码成 <span class="ui label tiny">/Web App Browser.html</span> 再查找文件。</p>
|
<p class="comment">是否对请求路径进行URL解码,比如把 <span class="ui label tiny">/Web+App+Browser.html</span> 解码成 <span class="ui label tiny">/Web App Browser.html</span> 再查找文件。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>是否终止请求</td>
|
<td>终止请求</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input type="checkbox" v-model="rootConfig.isBreak"/>
|
<input type="checkbox" v-model="config.isBreak"/>
|
||||||
<label></label>
|
<label></label>
|
||||||
</div>
|
</div>
|
||||||
<p class="comment">在找不到要访问的文件的情况下是否终止请求并返回404,如果选择终止请求,则不再尝试反向代理等设置。</p>
|
<p class="comment">在找不到要访问的文件的情况下是否终止请求并返回404,如果选择终止请求,则不再尝试反向代理等设置。</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user