Skip to content

Commit cb7beec

Browse files
paul-e-cooleydadoonet
authored andcommitted
Separate proxy traffic for ec2 and s3
Based on PR #178 by @paul-e-cooley. Thanks Paul! In addition to: ```yaml cloud: aws: protocol: https proxy_host: proxy1.company.com proxy_port: 8083 ``` You can also set different proxies for `ec2` and `s3`: ```yaml cloud: aws: s3: proxy_host: proxy1.company.com proxy_port: 8083 ec2: proxy_host: proxy2.company.com proxy_port: 8083 ``` PR rebased on master and lastest changes about component settings removal. Documentation added. Changes in tests. If a proxy is provided we run the tests, otherwise we ignore the test. Closes #177.
1 parent 7a7de12 commit cb7beec

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ cloud:
7070
proxy_port: 8083
7171
```
7272

73+
You can also set different proxies for `ec2` and `s3`:
74+
75+
```
76+
cloud:
77+
aws:
78+
s3:
79+
proxy_host: proxy1.company.com
80+
proxy_port: 8083
81+
ec2:
82+
proxy_host: proxy2.company.com
83+
proxy_port: 8083
84+
```
7385

7486
### Region
7587

src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java

+2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ public synchronized AmazonEC2 client() {
7676
String key = settings.get("cloud.aws.secret_key", settings.get("cloud.key"));
7777

7878
String proxyHost = settings.get("cloud.aws.proxy_host");
79+
proxyHost = settings.get("cloud.aws.ec2.proxy_host", proxyHost);
7980
if (proxyHost != null) {
8081
String portString = settings.get("cloud.aws.proxy_port", "80");
82+
portString = settings.get("cloud.aws.ec2.proxy_port", portString);
8183
Integer proxyPort;
8284
try {
8385
proxyPort = Integer.parseInt(portString, 10);

src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java

+2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ private synchronized AmazonS3 getClient(String endpoint, String protocol, String
104104
}
105105

106106
String proxyHost = settings.get("cloud.aws.proxy_host");
107+
proxyHost = settings.get("cloud.aws.s3.proxy_host", proxyHost);
107108
if (proxyHost != null) {
108109
String portString = settings.get("cloud.aws.proxy_port", "80");
110+
portString = settings.get("cloud.aws.s3.proxy_port", portString);
109111
Integer proxyPort;
110112
try {
111113
proxyPort = Integer.parseInt(portString, 10);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Licensed to Elasticsearch (the "Author") under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. Author licenses this
6+
* file to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.repositories.s3;
21+
22+
import org.elasticsearch.common.settings.Settings;
23+
import org.junit.Before;
24+
25+
/**
26+
* This will only run if you define in your `elasticsearch.yml` file a s3 specific proxy
27+
* cloud.aws.s3.proxy_host: mys3proxy.company.com
28+
* cloud.aws.s3.proxy_port: 8080
29+
*/
30+
public class S3ProxiedSnapshotRestoreOverHttpsTest extends AbstractS3SnapshotRestoreTest {
31+
32+
private boolean proxySet = false;
33+
34+
@Override
35+
public Settings nodeSettings(int nodeOrdinal) {
36+
Settings settings = super.nodeSettings(nodeOrdinal);
37+
String proxyHost = settings.get("cloud.aws.s3.proxy_host");
38+
proxySet = proxyHost != null;
39+
return settings;
40+
}
41+
42+
@Before
43+
public void checkProxySettings() {
44+
assumeTrue("we are expecting proxy settings in elasticsearch.yml file", proxySet);
45+
}
46+
47+
}

0 commit comments

Comments
 (0)