Cannot setup tus and uppy correctly on Apache

Started by neo1 reply1,535 views
neoOriginal post
#1

Hello everyone,

I am desperatly trying to make tus work correctly on my server.

At the moment I can upload a file from my front end with uppy to my back end. The uploading of files work fine but I cannot make it stop/resume. If I interrupt the upload I cannot resume it back. I have to wait one or two minute to be able to resume it back.

In the back end the file is locked and tus say that I cannot write on a locked file.
I see the file size growing even after interumpting the upload in the front. After a minute it stop growing and the lock disapear. After that I can resume my upload. But If I resume my upload before that it will fail and I have to restart from the beginning.

I will show you the apache2 configurations and the front end code.

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Video Portal</title>
	<link href="https://releases.transloadit.com/uppy/v2.3.1/uppy.min.css" rel="stylesheet">
	<script
        src="https://code.jquery.com/jquery-3.3.1.min.js"
        integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
        crossorigin="anonymous"></script>
	<script src="script.js" defer></script>
</head>
<body>
	<title>Test PHP</title>
	<div id="drag-drop-area"></div>

    <script src="https://releases.transloadit.com/uppy/v2.3.1/uppy.min.js"></script>
    <script>
      var uppy = new Uppy.Core()
        .use(Uppy.Dashboard, {
          inline: true,
          target: '#drag-drop-area'
        })
        // .use(Uppy.Tus, {endpoint: 'https://tusd.tusdemo.net/files/'})
        .use(Uppy.Tus, {endpoint: 'https://mywebsite.com/files'})

      uppy.on('complete', (result) => {
        console.log('Upload complete! We’ve uploaded these files:', result.successful)
      })
    </script>
	
</body>
</html>
<IfModule mod_ssl.c>
<VirtualHost *:443>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	ServerAdmin REDACTED@example.com
	ServerName mywebsite.com
	ServerAlias www.mywebsite.com
	DocumentRoot /var/www/mywebsite.live/public_html
	# DocumentRoot /var/www/example.com/html
	
	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

   	# In order that tusd can construct correct upload URLs, we tell tusd
   	# that the HTTPS protocol is used and also forward the original Host
   	# Header.
   	RequestHeader set X-Forwarded-Proto "https"
   	ProxyPreserveHost on

	# Pass requests to tusd server
	ProxyPass "/files" "http://localhost:1080/files"
    ProxyPassReverse "/files" "http://localhost:1080/files"
    ProxyPass "/metrics" "http://localhost:1080/metrics"
    ProxyPassReverse "/metrics" "http://localhost:1080/metrics"

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf
RewriteEngine on
# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.

# RewriteCond %{SERVER_NAME} =mywebsite.com [OR]
# RewriteCond %{SERVER_NAME} =www.mywebsite.com
# RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]


Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/www.mywebsite.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.mywebsite.com/privkey.pem
</VirtualHost>
</IfModule>

Thanks for your help,
Have a nice day.

marius
#2

Thank you for your report. Does the resuming work if you point Uppy directly to your tus server, i.e. without going through Apache first? Maybe the proxy is acting in a way that confuses the tus server. Also, what tus server are you using?