diff --git a/examples/nginx-contextpath/README.md b/examples/nginx-contextpath/README.md
index e4a190a..45d5234 100644
--- a/examples/nginx-contextpath/README.md
+++ b/examples/nginx-contextpath/README.md
@@ -41,10 +41,6 @@ YEAH! You are now using PlantUML behind a simple Nginx reverse proxy.
# PlantUML
location /plantuml/ {
- proxy_set_header HOST $host;
- proxy_set_header X-Forwarded-Host $host;
- proxy_set_header X-Forwarded-Proto $scheme;
-
proxy_pass http://plantuml-server:8080/plantuml/;
}
@@ -52,12 +48,31 @@ location /plantuml/ {
```
- `location /plantuml/` to reverse only the context path `/plantuml`
-- `proxy_set_header HOST $host` and `proxy_set_header X-Forwarded-Host $host` to replaces local plantuml server ip with FQDN
-- `proxy_set_header X-Forwarded-Proto $scheme` to use reverse proxy protocol schema instead of communication schema between reverse proxy and plantuml server
- `proxy_pass http://plantuml-server:8080/plantuml/` to set reverse proxy path to plantuml server.
Use the docker container name `plantuml-server` instead of ip addresses.
Also, use the same context path (`BASE_URL`) as PlantUML, which is configurable as an environment variable in the docker-compose file.
+NOTE: `BASE_URL`, `location` and therefore the `proxy_pass` should have the some context path!
+If that is not possible it may be possible to solve the problem by using NGINX `sub_filter`:
+```nginx
+# PlantUML
+location /plantuml/ {
+ sub_filter '' '';
+ sub_filter_types text/html;
+
+ proxy_pass http://plantuml-server:8080/;
+}
+```
+
+NOTE: Since [PR#256](https://github.com/plantuml/plantuml-server/pull/256) it is possible to use deep base URLs.
+So with e.g. `BASE_URL=foo/bar` the following is possible:
+```nginx
+# PlantUML
+location /foo/bar/ {
+ proxy_pass http://plantuml-server:8080/foo/bar/;
+}
+```
+
## Nginx and PlantUML server
diff --git a/examples/nginx-contextpath/nginx.conf b/examples/nginx-contextpath/nginx.conf
index e5f2852..6406659 100644
--- a/examples/nginx-contextpath/nginx.conf
+++ b/examples/nginx-contextpath/nginx.conf
@@ -18,10 +18,6 @@ http {
# PlantUML
location /plantuml/ {
- proxy_set_header HOST $host;
- proxy_set_header X-Forwarded-Host $host;
- proxy_set_header X-Forwarded-Proto $scheme;
-
proxy_pass http://plantuml-server:8080/plantuml/;
}
}
diff --git a/src/main/java/net/sourceforge/plantuml/servlet/PlantUmlServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/PlantUmlServlet.java
index cd83b63..1444a0b 100644
--- a/src/main/java/net/sourceforge/plantuml/servlet/PlantUmlServlet.java
+++ b/src/main/java/net/sourceforge/plantuml/servlet/PlantUmlServlet.java
@@ -254,17 +254,14 @@ public class PlantUmlServlet extends HttpServlet {
// properties
request.setAttribute("showSocialButtons", Configuration.get("SHOW_SOCIAL_BUTTONS"));
request.setAttribute("showGithubRibbon", Configuration.get("SHOW_GITHUB_RIBBON"));
- // URL base
- final String contextpath = request.getContextPath();
- request.setAttribute("contextpath", contextpath);
// image URLs
final boolean hasImg = !text.isEmpty();
request.setAttribute("hasImg", hasImg);
- request.setAttribute("imgurl", contextpath + "/png/" + index + encoded);
- request.setAttribute("svgurl", contextpath + "/svg/" + index + encoded);
- request.setAttribute("pdfurl", contextpath + "/pdf/" + index + encoded);
- request.setAttribute("txturl", contextpath + "/txt/" + index + encoded);
- request.setAttribute("mapurl", contextpath + "/map/" + index + encoded);
+ request.setAttribute("imgurl", "png/" + index + encoded);
+ request.setAttribute("svgurl", "svg/" + index + encoded);
+ request.setAttribute("pdfurl", "pdf/" + index + encoded);
+ request.setAttribute("txturl", "txt/" + index + encoded);
+ request.setAttribute("mapurl", "map/" + index + encoded);
// map for diagram source if necessary
final boolean hasMap = PlantumlUtils.hasCMapData(text);
request.setAttribute("hasMap", hasMap);
@@ -312,14 +309,13 @@ public class PlantUmlServlet extends HttpServlet {
String encoded,
Integer index
) throws IOException {
- final String result;
+ final String path;
if (index == null || index < 0) {
- result = request.getContextPath() + "/uml/" + encoded;
+ path = request.getContextPath() + "/uml/" + encoded;
} else {
- result = request.getContextPath() + "/uml/" + index + "/" + encoded;
+ path = request.getContextPath() + "/uml/" + index + "/" + encoded;
}
-
- response.sendRedirect(result);
+ response.sendRedirect(path);
}
/**
diff --git a/src/main/webapp/error.jsp b/src/main/webapp/error.jsp
index 8743344..53c9661 100644
--- a/src/main/webapp/error.jsp
+++ b/src/main/webapp/error.jsp
@@ -1,19 +1,16 @@
<%@ page isErrorPage="true" contentType="text/html; charset=utf-8" pageEncoding="utf-8" session="false" %>
-<%
- String contextpath = request.getContextPath();
-%>
-