Compare commits

...

5 Commits

Author SHA1 Message Date
c4de5afd4b java-raw: inner 2025-07-07 15:52:44 +03:00
f6e04d5ab9 java-raw: set config 2025-07-07 15:52:43 +03:00
925c6e96fc java-raw: add custom cors 2025-07-07 15:52:30 +03:00
bf873519de java-raw: idk project file 2025-07-07 15:52:29 +03:00
0df41b9e36 java-raw: add docker files 2025-07-07 15:52:29 +03:00
8 changed files with 200 additions and 55 deletions

View File

@ -1,23 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>OnlineEditorsExampleJava</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
<name>OnlineEditorsExampleJava</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
<filteredResources>
<filter>
<id>1690280351006</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

View File

@ -1,8 +1,22 @@
FROM maven:3.6.1-jdk-8-alpine AS MVN_BLDR
COPY ./ /tmp/
WORKDIR /tmp/
# FROM maven:3.9.3-eclipse-temurin-11-alpine AS example-build
# WORKDIR /srv
# COPY . .
# RUN mvn package
FROM maven:3.6.1-jdk-8-alpine AS example-build
WORKDIR /srv
COPY . .
RUN mvn package
FROM tomcat:alpine
RUN rm -fr /usr/local/tomcat/webapps/ROOT
COPY --from=MVN_BLDR /tmp/target/*.war $CATALINA_HOME/webapps/ROOT.war
# no main manifest attribute, in example.war
# FROM eclipse-temurin:11-jdk-alpine AS example
# WORKDIR /srv
# COPY --from=example-build /srv/target/*.war example.war
# CMD ["java", "-jar", "example.war"]
FROM tomcat:9.0.20-jre8-alpine AS example
RUN rm -rf /usr/local/tomcat/webapps/ROOT
COPY --from=example-build /srv/target/*.war $CATALINA_HOME/webapps/ROOT.war
FROM nginx:1.23.4-alpine3.17 AS proxy
COPY proxy/nginx.conf /etc/nginx/nginx.conf

View File

@ -1,9 +1,31 @@
version: '3'
version: "3.8"
services:
java-intg-ex:
build:
context: ./
dockerfile: Dockerfile
ports:
- 8080:8080
document-server:
container_name: document-server
image: onlyoffice/documentserver:7.3.3.50
expose:
- "80"
environment:
- JWT_SECRET=your-256-bit-secret
example:
container_name: example
build:
context: .
target: example
# platform: linux/amd64
expose:
# - "80"
- "8080"
proxy:
container_name: proxy
build:
context: .
target: proxy
ports:
# - "80:80"
# - "8080:8080"
- "8080:8080"
- "3000:3000"

View File

@ -0,0 +1,41 @@
worker_processes auto;
events {
worker_connections 512;
}
http {
include /etc/nginx/mime.types;
server {
# listen 80;
listen 8080;
server_name localhost;
location / {
proxy_http_version 1.1;
# proxy_pass http://example;
proxy_pass http://example:8080;
}
}
server {
# listen 8080;
listen 3000;
server_name localhost;
location / {
client_max_body_size 100m;
proxy_http_version 1.1;
proxy_pass http://document-server;
proxy_redirect off;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $http_x_forwarded_host;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header X-Real-IP $remote_addr;
}
}
}

View File

@ -0,0 +1,59 @@
/**
*
* (c) Copyright Ascensio System SIA 2023
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package controllers;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class CorsFilter implements Filter {
@Override
public void init(final FilterConfig filterConfig) throws ServletException {
}
@Override
public void destroy() {
}
@Override
public void doFilter(final ServletRequest request,
final ServletResponse response,
final FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse res = (HttpServletResponse) response;
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Credentials", "false");
res.setHeader("Access-Control-Allow-Methods", "*");
res.setHeader("Access-Control-Allow-Headers", "*");
if ("OPTIONS".equalsIgnoreCase(req.getMethod())) {
res.setStatus(HttpServletResponse.SC_OK);
} else {
filterChain.doFilter(request, response);
}
}
}

View File

@ -137,10 +137,24 @@ public final class TrackManager {
return body;
}
public static JSONObject resolveProcessSaveBody(final JSONObject body) {
JSONObject copied = body;
String url = (String) copied.get("url");
copied.put("url", url.replace("localhost", "proxy"));
String changesURL = (String) copied.get("changesurl");
copied.put("changesurl", changesURL.replace("localhost", "proxy"));
return copied;
}
// file saving process
public static void processSave(final JSONObject body,
public static void processSave(final JSONObject rawBody,
final String fileName,
final String userAddress) throws Exception {
JSONObject body = TrackManager.resolveProcessSaveBody(rawBody);
if (body.get("url") == null) {
throw new Exception("DownloadUrl is null");
}

View File

@ -7,16 +7,16 @@ enable-forgotten=TRUE
files.docservice.timeout=120000
files.docservice.url.site=http://documentserver/
files.docservice.url.site=http://localhost:3000/
files.docservice.url.converter=converter
files.docservice.url.command=command
files.docservice.url.api=web-apps/apps/api/documents/api.js
files.docservice.url.preloader=web-apps/apps/api/documents/preload.html
files.docservice.url.example=
files.docservice.url.example=http://proxy:8080/
files.docservice.languages=en:English|sq-AL:Albanian (Albania)|ar:Arabic|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|en-GB:English (United Kingdom)|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|he-IL:Hebrew (Israel)|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|sr-Cyrl-RS:Serbian (Cyrillic)|sr-Latn-RS:Serbian (Latin)|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|ur:Urdu|vi:Vietnamese|aa-AA:Test Language
files.docservice.secret=
files.docservice.secret=your-256-bit-secret
files.docservice.header=Authorization
files.docservice.token-use-for-request=TRUE
files.docservice.token-expiration=5

View File

@ -2,23 +2,7 @@
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET</param-value>
</init-param>
<init-param>
<param-name>cors.support.credentials</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>cors.exposed.headers</param-name>
<param-value>Access-Control-Allow-Origin,Access-Control-Allow-Methods</param-value>
</init-param>
<filter-class>controllers.CorsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>