Skip to content

Commit aa1e548

Browse files
feat: 网站反向代理增加协议选择 (#1832)
1 parent 80e845f commit aa1e548

File tree

7 files changed

+45
-10
lines changed

7 files changed

+45
-10
lines changed

backend/utils/files/fileinfo.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ func (f *FileInfo) search(search string, count int) (files []FileSearchInfo, tot
107107
if err = cmd.Start(); err != nil {
108108
return
109109
}
110-
defer cmd.Wait()
111-
defer cmd.Process.Kill()
110+
defer func() {
111+
_ = cmd.Wait()
112+
_ = cmd.Process.Kill()
113+
}()
112114

113115
scanner := bufio.NewScanner(output)
114116
for scanner.Scan() {

frontend/src/lang/modules/en.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ const message = {
13141314
value: 'value',
13151315
enable: 'Enable',
13161316
proxyAddress: 'Proxy Address',
1317-
proxyHelper: 'Example: http://127.0.0.1:8080',
1317+
proxyHelper: 'Example: 127.0.0.1:8080',
13181318
forceDelete: 'Force Delete',
13191319
forceDeleteHelper:
13201320
'Forced deletion will ignore errors generated during the deletion process and eventually delete metadata',
@@ -1471,6 +1471,7 @@ const message = {
14711471
'Switching the PHP version will delete the original PHP container (the website code that has been mounted will not be lost), continue? ',
14721472
changeVersion: 'Switch version',
14731473
retainConfig: 'Whether to keep php-fpm.conf and php.ini files',
1474+
runDirHelper2: 'Please ensure that the secondary running directory is under the index directory',
14741475
},
14751476
php: {
14761477
short_open_tag: 'Short tag support',
@@ -1489,6 +1490,8 @@ const message = {
14891490
disableFunction: 'Disable function',
14901491
disableFunctionHelper: 'Enter the function to be disabled, such as exec, please use multiple, split',
14911492
uploadMaxSize: 'Upload limit',
1493+
indexHelper:
1494+
'In order to ensure the normal operation of the PHP website, please place the code in the index directory and avoid renaming',
14921495
},
14931496
nginx: {
14941497
serverNamesHashBucketSizeHelper: 'The hash table size of the server name',

frontend/src/lang/modules/tw.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ const message = {
12571257
value: '值',
12581258
enable: '開啟',
12591259
proxyAddress: '代理地址',
1260-
proxyHelper: '例: http://127.0.0.1:8080',
1260+
proxyHelper: '例: 127.0.0.1:8080',
12611261
forceDelete: '強製刪除',
12621262
forceDeleteHelper: '強製刪除,會忽略刪除過程中產生的錯誤並最終刪除元數據',
12631263
deleteAppHelper: '同時刪除關聯應用、數據庫以及應用備份',
@@ -1404,6 +1404,7 @@ const message = {
14041404
changePHPVersionWarn: '切換 PHP 版本會刪除原有的 PHP 容器(不會丟失已經掛載的網站代碼),是否繼續? ',
14051405
changeVersion: '切換版本',
14061406
retainConfig: '是否保留 php-fpm.conf 和 php.ini 文件',
1407+
runDirHelper2: '請確保二級運行目錄位於 index 目錄下',
14071408
},
14081409
php: {
14091410
short_open_tag: '短標簽支持',
@@ -1422,6 +1423,7 @@ const message = {
14221423
disableFunction: '禁用函數',
14231424
disableFunctionHelper: '輸入要禁用的函數,例如exec,多個請用,分割',
14241425
uploadMaxSize: '上傳限製',
1426+
indexHelper: '為保障PHP網站正常運行,請將代碼放置於 index 目錄,並避免重命名',
14251427
},
14261428
nginx: {
14271429
serverNamesHashBucketSizeHelper: '服務器名字的hash表大小',

frontend/src/lang/modules/zh.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ const message = {
12571257
value: '值',
12581258
enable: '开启',
12591259
proxyAddress: '代理地址',
1260-
proxyHelper: '例: http://127.0.0.1:8080',
1260+
proxyHelper: '例: 127.0.0.1:8080',
12611261
forceDelete: '强制删除',
12621262
forceDeleteHelper: '强制删除,会忽略删除过程中产生的错误并最终删除元数据',
12631263
deleteAppHelper: '同时删除关联应用、数据库以及应用备份',
@@ -1281,7 +1281,7 @@ const message = {
12811281
primaryPath: '主目录',
12821282
folderTitle: '网站主目录主要包含四个文件夹',
12831283
wafFolder: '防火墙规则',
1284-
indexFolder: '网站root目录',
1284+
indexFolder: '网站 root 目录(PHP 运行环境 静态网站代码存放目录)',
12851285
logFolder: '网站日志',
12861286
sslFolder: '网站证书',
12871287
enableOrNot: '是否启用',
@@ -1404,6 +1404,7 @@ const message = {
14041404
changePHPVersionWarn: '切换 PHP 版本会删除原有的 PHP 容器(不会丢失已经挂载的网站代码),是否继续?',
14051405
changeVersion: '切换版本',
14061406
retainConfig: '是否保留 php-fpm.conf 和 php.ini 文件',
1407+
runDirHelper2: '请确保二级运行目录位于 index 目录下',
14071408
},
14081409
php: {
14091410
short_open_tag: '短标签支持',
@@ -1422,6 +1423,7 @@ const message = {
14221423
disableFunction: '禁用函数',
14231424
disableFunctionHelper: '输入要禁用的函数,例如exec,多个请用,分割',
14241425
uploadMaxSize: '上传限制',
1426+
indexHelper: '为保障 PHP 网站正常运行,请将代码放置于 index 目录,并避免重命名',
14251427
},
14261428
nginx: {
14271429
serverNamesHashBucketSizeHelper: '服务器名字的hash表大小',

frontend/src/styles/common.scss

+4
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,7 @@ html {
347347
.left-button {
348348
margin-left: 10px;
349349
}
350+
351+
.pre-select {
352+
width: 85px !important;
353+
}

frontend/src/views/website/website/config/basic/site-folder/index.vue

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
{{ $t('nginx.saveAndReload') }}
3131
</el-button>
3232
</el-space>
33+
<span class="input-help">
34+
{{ $t('website.runDirHelper2') }}
35+
</span>
3336
</el-form-item>
3437
<el-form-item v-if="configDir" :label="$t('website.userGroup')">
3538
<el-space wrap>
@@ -49,6 +52,7 @@
4952
<template #default>
5053
<span class="warnHelper">{{ $t('website.runDirHelper') }}</span>
5154
<span class="warnHelper">{{ $t('website.runUserHelper') }}</span>
55+
<span class="warnHelper">{{ $t('php.indexHelper') }}</span>
5256
</template>
5357
</el-alert>
5458
<br />

frontend/src/views/website/website/create/index.vue

+22-4
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
<el-select
224224
v-model="website.appinstall.memoryUnit"
225225
placeholder="Select"
226-
style="width: 85px"
226+
class="pre-select"
227227
>
228228
<el-option label="KB" value="K" />
229229
<el-option label="MB" value="M" />
@@ -268,8 +268,20 @@
268268
</span>
269269
</div>
270270
</el-form-item>
271-
<el-form-item v-if="website.type === 'proxy'" :label="$t('website.proxyAddress')" prop="proxy">
272-
<el-input v-model="website.proxy" :placeholder="$t('website.proxyHelper')"></el-input>
271+
<el-form-item
272+
v-if="website.type === 'proxy'"
273+
:label="$t('website.proxyAddress')"
274+
prop="proxyAddress"
275+
>
276+
<el-input v-model="website.proxyAddress" :placeholder="$t('website.proxyHelper')">
277+
<template #prepend>
278+
<el-select v-model="website.proxyProtocol" class="pre-select">
279+
<el-option label="http" value="http://" />
280+
<el-option label="https" value="https://" />
281+
<el-option :label="$t('website.other')" value="" />
282+
</el-select>
283+
</template>
284+
</el-input>
273285
</el-form-item>
274286
<el-form-item :label="$t('website.remark')" prop="remark">
275287
<el-input v-model="website.remark"></el-input>
@@ -348,6 +360,8 @@ const website = ref({
348360
IPV6: false,
349361
proxyType: 'tcp',
350362
port: 9000,
363+
proxyProtocol: 'http://',
364+
proxyAddress: '',
351365
});
352366
const rules = ref<any>({
353367
primaryDomain: [Rules.domain],
@@ -356,7 +370,7 @@ const rules = ref<any>({
356370
webSiteGroupId: [Rules.requiredSelectBusiness],
357371
appInstallId: [Rules.requiredSelectBusiness],
358372
appType: [Rules.requiredInput],
359-
proxy: [Rules.requiredInput],
373+
proxyAddress: [Rules.requiredInput],
360374
runtimeID: [Rules.requiredSelectBusiness],
361375
appinstall: {
362376
name: [Rules.appName],
@@ -549,6 +563,10 @@ const submit = async (formEl: FormInstance | undefined) => {
549563
loading.value = false;
550564
preCheckRef.value.acceptParams({ items: res.data });
551565
} else {
566+
if (website.value.type === 'proxy') {
567+
website.value.proxy = website.value.proxyProtocol + website.value.proxyAddress;
568+
console.log(website.value.proxy);
569+
}
552570
CreateWebsite(website.value)
553571
.then(() => {
554572
MsgSuccess(i18n.global.t('commons.msg.createSuccess'));

0 commit comments

Comments
 (0)