java spring boot, update nginx and docker compose
This commit is contained in:
parent
038cb33910
commit
5f198cfc20
6 changed files with 105 additions and 0 deletions
|
|
@ -7,6 +7,14 @@ services:
|
||||||
build: ./dotnet
|
build: ./dotnet
|
||||||
environment:
|
environment:
|
||||||
- NAME=Kili
|
- NAME=Kili
|
||||||
|
java-1:
|
||||||
|
build: ./java
|
||||||
|
environment:
|
||||||
|
- NAME=FiliJava
|
||||||
|
java-2:
|
||||||
|
build: ./java
|
||||||
|
environment:
|
||||||
|
- NAME=KiliJava
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx
|
image: nginx
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
||||||
25
java/.dockerignore
Normal file
25
java/.dockerignore
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
target/
|
||||||
|
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
.settings/
|
||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
|
||||||
|
tmp/
|
||||||
|
*.tmp
|
||||||
|
*.log
|
||||||
|
|
||||||
|
Dockerfile
|
||||||
|
Dockerfile.*
|
||||||
|
docker-compose.yaml
|
||||||
|
docker-compose.*.yaml
|
||||||
|
|
||||||
|
build/
|
||||||
|
|
||||||
|
.mvn
|
||||||
|
mvnw
|
||||||
|
mvnw.cmd
|
||||||
8
java/Dockerfile
Normal file
8
java/Dockerfile
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
FROM maven:3.9.6-eclipse-temurin-21
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN mvn clean package -DskipTests
|
||||||
|
|
||||||
|
ENTRYPOINT ["java", "-jar", "target/spring-boot-0.0.1-SNAPSHOT.jar"]
|
||||||
11
java/src/main/java/java_app/spring_boot/Application.java
Normal file
11
java/src/main/java/java_app/spring_boot/Application.java
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
package java_app.spring_boot;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class Application {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(Application.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package java_app.spring_boot;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class MirrorController {
|
||||||
|
|
||||||
|
private final String serverName = System.getenv().getOrDefault("NAME", "unnamed");
|
||||||
|
|
||||||
|
@GetMapping(path = "/**") // Obsługuje dowolną ścieżkę
|
||||||
|
public String mirrorRequest(HttpServletRequest request) {
|
||||||
|
|
||||||
|
String ip = request.getRemoteAddr();
|
||||||
|
String method = request.getMethod();
|
||||||
|
String scheme = request.getScheme();
|
||||||
|
String host = request.getHeader(HttpHeaders.HOST);
|
||||||
|
String path = request.getRequestURI();
|
||||||
|
String queryString = request.getQueryString() != null ? "?" + request.getQueryString() : "";
|
||||||
|
|
||||||
|
StringBuilder responseText = new StringBuilder();
|
||||||
|
|
||||||
|
responseText.append("Server Name: ").append(serverName).append("\n");
|
||||||
|
responseText.append("IP Address (Remote): ").append(ip).append("\n");
|
||||||
|
responseText.append("Method: ").append(method).append("\n");
|
||||||
|
responseText.append("Scheme: ").append(scheme).append("\n");
|
||||||
|
responseText.append("Host: ").append(host).append("\n");
|
||||||
|
responseText.append("Path: ").append(path).append("\n");
|
||||||
|
responseText.append("QueryString: ").append(queryString).append("\n");
|
||||||
|
responseText.append("Headers:\n");
|
||||||
|
|
||||||
|
request.getHeaderNames().asIterator().forEachRemaining(headerName -> {
|
||||||
|
responseText.append(" ").append(headerName).append(": ").append(request.getHeader(headerName)).append("\n");
|
||||||
|
});
|
||||||
|
|
||||||
|
return "<pre>" + responseText.toString() + "</pre>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,11 @@ http {
|
||||||
server dotnet-2;
|
server dotnet-2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
upstream java_app {
|
||||||
|
server java-1;
|
||||||
|
server java-2;
|
||||||
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
|
|
||||||
|
|
@ -24,5 +29,14 @@ http {
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location /java/ {
|
||||||
|
proxy_pass http://java_app;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue