|
@@ -25,9 +25,30 @@ public class DemoController {
|
|
|
|
|
|
@GetMapping("/showme")
|
|
|
public String trySomething() throws IOException {
|
|
|
- String clientIp = request.getRemoteAddr();
|
|
|
+ String clientIp = getClientIp();
|
|
|
return clientIp;
|
|
|
}
|
|
|
+
|
|
|
+ public String getClientIp() {
|
|
|
+ String clientIp = request.getHeader("X-Forwarded-For");
|
|
|
+ if (clientIp == null || clientIp.isEmpty() || "unknown".equalsIgnoreCase(clientIp)) {
|
|
|
+ clientIp = request.getHeader("Proxy-Client-IP");
|
|
|
+ }
|
|
|
+ if (clientIp == null || clientIp.isEmpty() || "unknown".equalsIgnoreCase(clientIp)) {
|
|
|
+ clientIp = request.getHeader("WL-Proxy-Client-IP");
|
|
|
+ }
|
|
|
+ if (clientIp == null || clientIp.isEmpty() || "unknown".equalsIgnoreCase(clientIp)) {
|
|
|
+ clientIp = request.getHeader("HTTP_X_FORWARDED_FOR");
|
|
|
+ }
|
|
|
+ if (clientIp == null || clientIp.isEmpty() || "unknown".equalsIgnoreCase(clientIp)) {
|
|
|
+ clientIp = request.getHeader("HTTP_CLIENT_IP");
|
|
|
+ }
|
|
|
+ if (clientIp == null || clientIp.isEmpty() || "unknown".equalsIgnoreCase(clientIp)) {
|
|
|
+ clientIp = request.getRemoteAddr();
|
|
|
+ }
|
|
|
+ return clientIp;
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/setCookie")
|
|
|
public String setCookie() throws IOException {
|
|
|
// Define the proxy server details
|