Nginx Module

Nginx is a web server, reverse proxy and mail proxy and http cache.

Usage example

The following example shows how to start Nginx.

public NginxContainer<?> nginx = new NginxContainer<>(NGINX_IMAGE)
    .waitingFor(new HttpWaitStrategy());

How to add custom content to the Nginx server.

// Create a temporary dir
File contentFolder = new File(tmpDirectory);

// And "hello world" HTTP file
File indexFile = new File(contentFolder, "index.html");
@Cleanup PrintStream printStream = new PrintStream(new FileOutputStream(indexFile));
printStream.println("<html><body>Hello World!</body></html>");

And how to query the Nginx server for the custom content added.

URL baseUrl = nginx.getBaseUrl("http", 80);

assertThat("An HTTP GET from the Nginx server returns the index.html from the custom content directory",
    containsString("Hello World!")

Adding this module to your project dependencies

Add the following dependency to your pom.xml/build.gradle file:

testImplementation "org.testcontainers:nginx:1.16.0"