]> jfr.im git - uguu.git/commitdiff
changes
authorGo Johansson (neku) <redacted>
Sun, 1 Jan 2023 10:27:49 +0000 (11:27 +0100)
committerGo Johansson (neku) <redacted>
Sun, 1 Jan 2023 10:27:49 +0000 (11:27 +0100)
Makefile
docker/Dockerfile
docker/nginx/nginx.conf [new file with mode: 0644]
src/Classes/Upload.php
src/config.json
src/templates/tools.ejs

index 248f1921a7e9097b96f2cd43fbf9940624ca3a15..cf69cf8455188ad46c8c18974ad583296b3fbc4b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,7 @@ CURL = "curl"
 DESTDIR = $(shell $(CURDIR)/$(NODEJQ) -r ".dest" $(CURDIR)/$(CONF))
 SITEDOMAIN = $(shell $(CURDIR)/$(NODEJQ) -r ".DOMAIN" $(CURDIR)/$(CONF))
 FILESDOMAIN = $(shell $(CURDIR)/$(NODEJQ) -r ".FILE_DOMAIN" $(CURDIR)/$(CONF))
+MAXSIZE = $(shell $(CURDIR)/$(NODEJQ) -r ".max_upload_size" $(CURDIR)/$(CONF))
 CONTACT_EMAIL = $(shell $(CURDIR)/$(NODEJQ) -r ".infoContact" $(CURDIR)/$(CONF))
 PKG_VERSION = $(shell $(CURDIR)/$(NODEJQ) -r ".version" $(CURDIR)/package.json)
 TMPDIR = $(shell mktemp -d)
@@ -97,7 +98,7 @@ build-container-no-cache:
 build-container:
                tar --exclude='uguuForDocker.tar.gz' --exclude='vendor' --exclude='node_modules' --exclude='build' --exclude='dist' --exclude='.git' -czf uguuForDocker.tar.gz .
                mv uguuForDocker.tar.gz docker/
-               docker build -f docker/Dockerfile --build-arg DOMAIN=$(SITEDOMAIN) --build-arg FILE_DOMAIN=$(FILESDOMAIN) --build-arg CONTACT_EMAIL=$(FILESDOMAIN) -t uguu:$(PKG_VERSION) .
+               docker build -f docker/Dockerfile --build-arg DOMAIN=$(SITEDOMAIN) --build-arg FILE_DOMAIN=$(FILESDOMAIN) --build-arg CONTACT_EMAIL=$(FILESDOMAIN) --build-arg MAX_SIZE=$(MAXSIZE) -t uguu:$(PKG_VERSION) .
 
 run-container:
                docker run --name uguu -d -p 80:80 -p 443:443 uguu:$(PKG_VERSION)
index 4ec2ea8972841b57c72c2a9d8dbdf450de129f76..8985fe05386e2deaf981ffdd8fb05b431ff5cb84 100644 (file)
@@ -24,6 +24,8 @@ ARG FILE_DOMAIN
 ENV FILE_DOMAIN=$FILE_DOMAIN
 ARG CONTACT_EMAIL
 ENV CONTACT_EMAIL=$CONTACT_EMAIL
+ARG MAX_SIZE
+ENV MAX_SIZE=$MAX_SIZE
 
 # Set default workdir
 WORKDIR  /var/www/
@@ -56,12 +58,16 @@ RUN chmod a+x /var/www/uguu/src/static/scripts/checkdb.sh && \
 
 # Copy Nginx Server conf
 COPY docker/nginx/uguu.conf /etc/nginx/sites-enabled/uguu.conf
+COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf
 
+# Modify nginx values
 RUN sed -i "s#XMAINDOMAINX#${DOMAIN}#g" /etc/nginx/sites-enabled/uguu.conf
 RUN sed -i "s#XFILESDOMAINX#${FILE_DOMAIN}#g" /etc/nginx/sites-enabled/uguu.conf
+RUN sed -i "s#client_max_body_size 128M#$client_max_body_size {MAX_SIZE}M#g" /etc/nginx/nginx.conf
 
-# Copy SSL certs
-#COPY docker/ssl /etc/ssl
+# Modify php-fpm values
+RUN sed -i "s#post_max_size = 8M#post_max_size = ${MAX_SIZE}M#g" /etc/php/8.1/fpm/php.ini
+RUN sed -i "s#upload_max_filesize = 2M#upload_max_filesize = ${MAX_SIZE}M#g" /etc/php/8.1/fpm/php.ini
 
 # Copy Uguu config
 COPY src/config.json /var/www/uguu/config.json
diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf
new file mode 100644 (file)
index 0000000..e962754
--- /dev/null
@@ -0,0 +1,62 @@
+user www-data;
+worker_processes auto;
+pid /run/nginx.pid;
+include /etc/nginx/modules-enabled/*.conf;
+
+events {
+        worker_connections 768;
+        # multi_accept on;
+}
+
+http {
+
+        ##
+        # Basic Settings
+        ##
+
+        sendfile on;
+        tcp_nopush on;
+        types_hash_max_size 2048;
+        client_max_body_size 128M;
+        # server_tokens off;
+
+        # server_names_hash_bucket_size 64;
+        # server_name_in_redirect off;
+
+        include /etc/nginx/mime.types;
+        default_type application/octet-stream;
+
+        ##
+        # SSL Settings
+        ##
+
+        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
+        ssl_prefer_server_ciphers on;
+
+        ##
+        # Logging Settings
+        ##
+
+        access_log /var/log/nginx/access.log;
+        error_log /var/log/nginx/error.log;
+
+        ##
+        # Gzip Settings
+        ##
+
+        gzip on;
+
+        # gzip_vary on;
+        # gzip_proxied any;
+        # gzip_comp_level 6;
+        # gzip_buffers 16 8k;
+        # gzip_http_version 1.1;
+        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
+
+        ##
+        # Virtual Host Configs
+        ##
+
+        include /etc/nginx/conf.d/*.conf;
+        include /etc/nginx/sites-enabled/*;
+}
\ No newline at end of file
index 604463cde236bb8937d2102d9cceb49b32006eac..79d7ab437b660277738fc51939808dce8a53ded0 100644 (file)
@@ -170,7 +170,7 @@ class Upload extends Response
         return [
            'hash' => $this->FILE_INFO['SHA1'],
            'name' => $this->FILE_INFO['NAME'],
-           'url'  => $this->Connector->CONFIG['FILES_URL'] . '/' . $this->FILE_INFO['NEW_NAME'],
+           'url'  => 'https://' . $this->Connector->CONFIG['FILE_DOMAIN'] . '/' . $this->FILE_INFO['NEW_NAME'],
            'size' => $this->FILE_INFO['SIZE'],
         ];
     }
index 9759b6901c7620d51080cee1b969caa07ddc60d5..89a47635326a46f018b6fbd0f7f5b1035c91042a 100755 (executable)
@@ -15,7 +15,6 @@
   "subTitle": "wahooo",
   "DOMAIN": "domain.com",
   "FILE_DOMAIN": "files.domain.com",
-  "siteUrl": "https://domain.com",
   "abuseContact": "abuse@example.com",
   "infoContact": "info@example.com",
   "ServerCountryLocation": "Sweden",
@@ -28,7 +27,7 @@
   "kofiUrl": "",
   "malwareBanner": false,
   "DB_MODE": "sqlite",
-  "DB_PATH": "/var/www/db/uguu.sq3",
+  "DB_PATH": "/var/www/db/uguuDB.sq3",
   "DB_USER": "NULL",
   "DB_PASS": "NULL",
   "LOG_IP": false,
@@ -40,7 +39,6 @@
   "RATE_LIMIT_FILES": 100,
   "FILES_ROOT": "/var/www/files/",
   "FILES_RETRIES": 15,
-  "FILES_URL": "https://files.domain.com",
   "NAME_LENGTH": 8,
   "ID_CHARSET": "abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ",
   "DOUBLE_DOTS_EXTENSIONS": [
index d773257a71add03e8842fd2879f7ae65a3a57719..5d761b44522a0c5889317367356bcf877b3f0cb8 100644 (file)
@@ -8,9 +8,9 @@
             <h3>
                 To upload using curl or make a tool you can post using:
                 <br>
-                curl -i -F files[]=@yourfile.jpeg <%= siteUrl %>/upload.php (JSON Response)
+                curl -i -F files[]=@yourfile.jpeg <%= DOMAIN %>/upload.php (JSON Response)
             </h3>
-            <p>To upload using curl or make a tool you can post using: curl -i -F files[]=@yourfile.jpeg <%= siteUrl %>/upload.php (JSON Response)</p>
+            <p>To upload using curl or make a tool you can post using: curl -i -F files[]=@yourfile.jpeg <%= DOMAIN %>/upload.php (JSON Response)</p>
             <section>
                 <h2>ShareX</h2>
                 <dl>