-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix compatibility with mod_rewrite in proxy mode
mod_rewrite passes cookies to the backend servers when run in proxy mode. For us this is helpful as our single-sign-on solution is cookie based. We use mod_rewrite to map backend APIs to our frontend servers and thus fix the CORS problem. When testing urlrewritefilter as an alternative solution I noticed, that my requests were all redirected to our authentication servers and the dropped cookies would cause that behavior. This triggered my investigation.
- Loading branch information
1 parent
3385a51
commit e5c7362
Showing
6 changed files
with
69 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...ple-webapp/src/main/java/org/tuckey/web/filters/urlrewriteviacontainer/CookieServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
package org.tuckey.web.filters.urlrewriteviacontainer; | ||
|
||
import jakarta.servlet.ServletException; | ||
import jakarta.servlet.http.Cookie; | ||
import jakarta.servlet.http.HttpServlet; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
import java.io.Writer; | ||
|
||
public class CookieServlet extends HttpServlet { | ||
|
||
@Override | ||
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { | ||
try (Writer writer = resp.getWriter()) { | ||
writer.write("Cookie-Servlet\n"); | ||
for(Cookie cookie: req.getCookies()) { | ||
writer.write(cookie.getName()); | ||
writer.write((": ")); | ||
writer.write(cookie.getValue()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters