Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ include::{topics}/ref_hotrod_cpp_tutorials.adoc[leveloffset=+1]
include::{topics}/ref_cross_site_replication.adoc[leveloffset=+1]
include::{topics}/ref_secured_with_token_keycloak.adoc[leveloffset=+1]
include::{topics}/ref_tracing_opentelemetry.adoc[leveloffset=+1]
include::{topics}/ref_reverse-proxy-nginx.adoc[leveloffset=+1]
endif::community[]

// Restore the parent context.
Expand Down
23 changes: 23 additions & 0 deletions documentation/asciidoc/topics/ref_reverse-proxy-nginx.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[id='reverse-proxy-nginx_{context}']
= Reverse proxy example with NGINX

Learn how to handle reverse proxy configuration in {brandname} with a NGINX.

In this tutorial, you start one {brandname} cluster and NGINX using `docker-compose`.

== Docker compose

[WARNING]
====
Make sure you have `docker` and `docker-compose` installed locally.
====

.Steps

. Run `docker-compose up`. NGINX and {brandname} will start with all the necessary configuration.

. Access the console at `http://localhost:8080/infinispan/console/welcome`.

. Enter 'admin/password' credentials in the login pop up (BASIC Authentication).

. You are now logged in.
24 changes: 24 additions & 0 deletions infinispan-remote/reverse-proxy-infinispan/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.8'

services:
infinispan:
image: quay.io/infinispan-test/server:main
container_name: infinispan
environment:
USER: admin
PASS: password
volumes:
- ./infinispan-basic-auth.xml:/user-config/infinispan-basic-auth.xml
command: -c infinispan.xml -c /user-config/infinispan-basic-auth.xml
ports:
- "11222:11222"

nginx:
image: nginx:latest
container_name: nginx-proxy
ports:
- "8080:8080"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- infinispan
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<infinispan>
<server>
<endpoints>
<endpoint socket-binding="default" security-realm="default">
<rest-connector>
<authentication mechanisms="BASIC"/>
<cors-rules>
<cors-rule name="ngynx"
allow-credentials="true"
max-age-seconds="3600"
allowed-origins="http://localhost:8080"
allowed-methods="GET POST PUT DELETE OPTIONS"
allowed-headers="Authorization Content-Type,Accept"
expose-headers="Content-Type Accept"/>
</cors-rules>
</rest-connector>
</endpoint>
</endpoints>
</server>
</infinispan>
39 changes: 39 additions & 0 deletions infinispan-remote/reverse-proxy-infinispan/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
events {}

http {
server {
listen 8080;

# Frontend App: Infinispan Console
# Serves the console UI (HTML/JS/CSS) at /infinispan/console/
# X-Forwarded-Prefix tells the backend the base path of the console
location /infinispan/console/ {
proxy_pass http://infinispan:11222/console/;
proxy_set_header X-Forwarded-Prefix /infinispan;
}

# # Optional: override config.js path if you want console and API
# # in different locations (e.g., "/api/"). Uncomment if needed.
# location /infinispan/console/config.js {
# proxy_pass http://infinispan:11222/console/config.js;
# proxy_set_header X-Forwarded-Prefix /api;
# }

# API Requests: all other paths under /infinispan/
# Forwards requests to the Infinispan backend API
# - Host header preserved
# - Authorization header forwarded if provided by the client
# - Original client IP forwarded via X-Real-IP and X-Forwarded-For
# - HTTP 1.1 connection used for keep-alive
location /infinispan/ {
proxy_pass http://infinispan:11222/;
proxy_set_header Host $host;
proxy_set_header Authorization $http_authorization;
proxy_pass_header Authorization;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
}
}