mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 21:50:28 +08:00 
			
		
		
		
	可以配置是否在反向代理中添加X-Real-IP和X-Forwarded-*
This commit is contained in:
		@@ -86,6 +86,7 @@ func (this *SettingAction) RunPost(params struct {
 | 
			
		||||
		RequestURI:      reverseProxyConfig.RequestURI,
 | 
			
		||||
		StripPrefix:     reverseProxyConfig.StripPrefix,
 | 
			
		||||
		AutoFlush:       reverseProxyConfig.AutoFlush,
 | 
			
		||||
		AddHeaders:      reverseProxyConfig.AddHeaders,
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	this.Success()
 | 
			
		||||
 
 | 
			
		||||
@@ -86,6 +86,7 @@ func (this *SettingAction) RunPost(params struct {
 | 
			
		||||
		RequestURI:      reverseProxyConfig.RequestURI,
 | 
			
		||||
		StripPrefix:     reverseProxyConfig.StripPrefix,
 | 
			
		||||
		AutoFlush:       reverseProxyConfig.AutoFlush,
 | 
			
		||||
		AddHeaders:      reverseProxyConfig.AddHeaders,
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	this.Success()
 | 
			
		||||
 
 | 
			
		||||
@@ -17,14 +17,43 @@ Vue.component("reverse-proxy-box", {
 | 
			
		||||
                stripPrefix: "",
 | 
			
		||||
                requestURI: "",
 | 
			
		||||
                requestHost: "",
 | 
			
		||||
				requestHostType: 0
 | 
			
		||||
                requestHostType: 0,
 | 
			
		||||
                addHeaders: []
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        let forwardHeaders = [
 | 
			
		||||
            {
 | 
			
		||||
                name: "X-Real-IP",
 | 
			
		||||
                isChecked: false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                name: "X-Forwarded-For",
 | 
			
		||||
                isChecked: false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                name: "X-Forwarded-By",
 | 
			
		||||
                isChecked: false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                name: "X-Forwarded-Host",
 | 
			
		||||
                isChecked: false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                name: "X-Forwarded-Proto",
 | 
			
		||||
                isChecked: false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
        forwardHeaders.forEach(function (v) {
 | 
			
		||||
            v.isChecked = reverseProxyConfig.addHeaders.$contains(v.name)
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
        return {
 | 
			
		||||
            reverseProxyRef: reverseProxyRef,
 | 
			
		||||
            reverseProxyConfig: reverseProxyConfig,
 | 
			
		||||
            advancedVisible: false,
 | 
			
		||||
            family: this.vFamily
 | 
			
		||||
            family: this.vFamily,
 | 
			
		||||
            forwardHeaders: forwardHeaders
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    watch: {
 | 
			
		||||
@@ -42,6 +71,13 @@ Vue.component("reverse-proxy-box", {
 | 
			
		||||
        },
 | 
			
		||||
        changeAdvancedVisible: function (v) {
 | 
			
		||||
            this.advancedVisible = v
 | 
			
		||||
        },
 | 
			
		||||
        changeAddHeader: function () {
 | 
			
		||||
            this.reverseProxyConfig.addHeaders = this.forwardHeaders.filter(function (v) {
 | 
			
		||||
                return v.isChecked
 | 
			
		||||
            }).map(function (v) {
 | 
			
		||||
                return v.name
 | 
			
		||||
            })
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    template: `<div>
 | 
			
		||||
@@ -77,6 +113,16 @@ Vue.component("reverse-proxy-box", {
 | 
			
		||||
		</tbody>
 | 
			
		||||
		<more-options-tbody @change="changeAdvancedVisible" v-if="isOn()"></more-options-tbody>
 | 
			
		||||
		<tbody v-show="isOn() && advancedVisible">
 | 
			
		||||
		    <tr v-show="family == null || family == 'http'">
 | 
			
		||||
		        <td>自动添加的Header</td>
 | 
			
		||||
		        <td>
 | 
			
		||||
		            <div>
 | 
			
		||||
		                <div style="width: 20em; float: left; margin-bottom: 1em" v-for="header in forwardHeaders" :key="header.name">
 | 
			
		||||
		                    <checkbox v-model="header.isChecked" @input="changeAddHeader">{{header.name}}</checkbox>
 | 
			
		||||
                        </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                </td> 
 | 
			
		||||
            </tr>
 | 
			
		||||
			<tr v-show="family == null || family == 'http'">
 | 
			
		||||
				<td>请求URI<em>(RequestURI)</em></td>
 | 
			
		||||
				<td>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user