Skip to content

Commit 87c57ab

Browse files
authored
Merge pull request #1534 from marklogic/feature/rps-readme
Added README for using the reverse proxy to emulate MarkLogic Cloud
2 parents 914b17b + d095a05 commit 87c57ab

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

test-app/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is an ml-gradle project for deploying a test application to MarkLogic that the tests in ./marklogic-client-api and
2+
most of the tests in ./marklogic-client-api-functional-tests depends on.
3+
4+
To deploy it, run this from the root directory of this repository:
5+
6+
./gradlew -i mlDeploy
7+
8+
## Running the reverse proxy
9+
10+
This project also includes a Gradle task for running a reverse proxy server using [Undertow](https://undertow.io/).
11+
This is intended to support testing the use of a "base path" parameter with the Java Client and to also do a reasonable
12+
job of emulating how MarkLogic Cloud works.
13+
14+
Note - the reverse proxy server only supports basic authentication, not digest authentication. Thus, you need to ensure
15+
that any MarkLogic app server that you proxy requests to supports either "digestbasic" or "basic" for authentication.
16+
That includes your Admin, Manage, and App-Services app servers.
17+
18+
To run the server, run the following:
19+
20+
./gradlew runBlockingReverseProxyServer
21+
22+
By default, this will listen on port 8020 and proxy requests based on the mapping that it logs when the server is
23+
started up.
24+
25+
To emulate how MarkLogic Cloud works, run the following (you can use `runBlock` as an abbreviation, Gradle will figure
26+
out what you mean):
27+
28+
sudo ./gradlew runBlock -PrpsHttpsPort=443
29+
30+
This will result in the server listening for HTTPS requests on port 443; sudo is required since this listens to a port
31+
under 1024.
32+
33+
You can also specify custom mappings via the Gradle task. For example, if you have a MarkLogic app server listening on
34+
port 8123 and you want to associate a path of "/my/custom/server" to it, you can do:
35+
36+
./gradlew runBlock -PrpsCustomMappings=/my/custom/server,8123

test-app/src/main/java/com/marklogic/client/test/ReverseProxyServer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import io.undertow.util.Headers;
3636
import okhttp3.Credentials;
3737
import org.springframework.core.io.ClassPathResource;
38+
import org.springframework.util.StringUtils;
3839
import org.xnio.IoUtils;
3940
import org.xnio.OptionMap;
4041

@@ -100,7 +101,7 @@ public static void main(final String[] args) throws Exception {
100101
serverPort = Integer.parseInt(args[2]);
101102
if (args.length > 3) {
102103
secureServerPort = Integer.parseInt(args[3]);
103-
if (args.length > 4) {
104+
if (args.length > 4 && StringUtils.hasText(args[4])) {
104105
customMappings = Arrays.asList(args[4].split(","));
105106
}
106107
}

0 commit comments

Comments
 (0)