Static gallery (images, videos with subtitles, other files) on the top of the nginx web server.
Just put your files in the folder and get it instantly in the gallery - no background service is running, files are read directly from your file system. With the XSTL is directory listing converted to an HTML page with some controlling JavaScript and CSS.
- images...
- reading EXIF (via exifr)
- show GPS on the Google Maps
- view photo sphere panoramas (via Photo Sphere Viewer)
- an optional automatic image thumbnails with an optional cache
- videos (via Plyr)
- an optional thumbnail generation (
ffmpeg
installed on system needed) - with optional auto conversion SRT subtitles to supported VTT
- an optional thumbnail generation (
- other files (just view and download)
- sharing link to the gallery
- sharing on social networks (via shareon)
- as lightbox is used GLightbox
- HTTP or HTTPS (Let's encrypt support - via external tools - dehyhrated for example)
- custom gallery title/favicon and many more settings
- password access (via HTTP Basic Auth)
nginx to run gallery and node.js version 16 or greater with npm
to generate configuration. If you want to generate also video thumbnails, ffmpeg
must be installed on your system. Nothing more, really. This tool generates nginx configuration and one XSLT, JS and CSS file to control whole gallery and all supported tools.
You need nginx with the XSTL module. In Debian/Ubuntu world this is the nginx-full
package.
If you want an automatic image thumbnail (with a cache) you need also the images filter module. Still the nginx-full
in Debian/Ubuntu.
For an automatic SRT to VTT conversion you need the lua module. This is the nginx-extras
package.
And for video thumbnails generation you also need the lua module
and ffmpeg installed on your system and binaries must be set in PATH
(you can run ffmpeg
command from everywhere). Thumbnail generation was tested on ffmpeg
version 4.3.0
.
This configuration generator was tested on the linux only.
Clone this repository or download source files from GitHub and install npm modules with npm install
.
Then you need configuration file in YAML:
nginxConfDir: /etc/nginx/sites-available/
nginxAppDir: /etc/nginx/apps/static-nginx-gallery/
serverName: gallery.test
galleryDir: /var/www/gallery
These are the only 4 required items you always must specify:
nginxConfDir
- where nginx configuration file will be generated (file will havestatic-nginx-gallery
name) - don't forget to enable configuration in nginx, when it's not generated into included files - in Debiansudo ln -s /etc/nginx/sites-available/static-nginx-gallery /etc/nginx/sites-enabled/static-nginx-gallery
andsudo service nginx reload
nginxAppDir
- where the other (XSLT
,JS
andCSS
) files will be storedserverName
- domain where the gallery will be accessiblegalleryDir
- root directory with all your files (you can access also all subdirectories)
There are some more optional options:
path: null # /path/
port: null # null = use default - 80 for HTTP, 443 for HTTPS
thumbnails: false # bool - yes/no or string with cache directory
videoThumbnails: false # or string with cache directory
lightTheme: false # bool - yes/no
title: 'Gallery' # <h1> and <title>
favicon: false # or string with a path to custom favicon (in PNG format)
subtitles:
convertSrtToVtt: false
ssl: false # explain later
httpAuth: false # or string with htpasswd auth file
path
- by default, gallery is accessible at serverName host/
, this can change the default path topath
(for examplehttp://gallery.test/some-path/
it you setserverName: gallery.test
andpath: 'some-path'
)port
-null
is used for default value -80
for HTTP or443
for HTTPS version, but you can use your own, if you needthumbnails
- by default, thumbnail images in the list are original images, this could cause to download a lot of data for one page. When you set this totrue
, nginx will generate for all images smaller thumbnails on the fly, so data usage will be less, but more processor time will be used to generate thumbnails on every request. The last option is to provide astring
with a directory, where this thumbnails will be cached, so every thumbnail will be generated just once. This has just one disadvantage: when a thumbnail is generated, it's never regenerated, even if the original image is changed. You must remove cached thumbnail to regenerate it.images
module is needed in nginx for thisvideoThumbnails
- by default, videos has no thumbnail images. When you set directory for cache, nginx will generate viaffmpeg
thumbnails and these thumbnails will be cached, so every thumbnail will be generated just once. This has the same disadvantage as image thumbnails: when a thumbnail is generated, it's never regenerated, even if the original video is changed. You must remove cached thumbnail to regenerate it.lua
module is needed in nginx for this andffmpeg
must be installed on the systemlightTheme
- gallery is by default in dark theme, set this totrue
and light theme will be usedtitle
- can change default<title>
and<h1>
which isGallery
favicon
- can change default favicon file, use path to a PNG imagesubtitels
->convertSrtToVtt
- if set totrue
try to automatically convert existing SRT subtitles to VTT (only VTT subtitles are supported in video player) -LUA
module is needed in nginxhttpAuth
- use can specify astring
with a path to htpasswd file for enabling user/password access to the gallery
How to generate
htpasswd
file? In linux with installedopenssl
you can useprintf "USER:$(openssl passwd -crypt PASSWORD)\n" >> .htpasswd
- just changeUSER
with the correct username andPASSWORD
with the correct password..htpasswd
is path to the generated file.
In most cases, you want to run your gallery on HTTPS protocol. You can also use own HTTPS (or other, for example for access restriction I can recommend oauth2-proxy) proxy and keep running gallery on HTTP:
ssl:
certificate: '/etc/letsencrypt/certs/gallery.test/fullchain.pem' # required if ssl is set
certificateKey: '/etc/letsencrypt/certs/gallery.test/privkey.pem' # required if ssl is set
redirectHttpToHttps: true # bool - yes/no
httpPort: 80 # HTTP port to redirect to HTTPS or for Let's encrypt (if Let's encrypt is used, must be 80)
letsEncrypt: false # or string with a path to directory to store ACME challenge
certificate
- path to SSL certificate, requiredcertificateKey
- path to SSL certificate key, requiredredirectHttpToHttps
- by default, for HTTPS is also generated a HTTP block, that just redirect HTTP to HTTPS. If you don't need this, set config tofalse
httpPort
- belongs to the previous config, set port for HTTP block for redirect, default is80
. If you use Let's encrypt config, you must keep it to80
.letsEncrypt
- whenstring
path is provided, to HTTP block is generated snippet to enable auto generating Let's encrypt certificates. You also need some tool to generate certificates, for example dehyhrated. Before first certificate is generated, you must comment SSL certificate and SSL certificate key lines.
So, we have config.yml
with our configuration, now just run:
bin/build config.yml
or:
npm run build config.yml
You will probably need root
rights to proper save configuration, so use:
sudo bin/build config.yml
And after that don't forget to reload your nginx configuration. In Debian/Ubuntu like this:
sudo service nginx reload
You can also add -d
or --debug
option to disable JS and CSS minimization.
It's recommended to add this option to main nginx configuration, the http
section:
variables_hash_max_size 4096
In Debian/Ubuntu in file /etc/nginx/nginx.conf
.
You can make your own changes in CSS, JavaScript and HTML structure.
CSS is in the src/sass/main.scss file and is compiled with the SASS preprocessor.
JavaScript is in the src/js/main.js file and is compiled with the Rollup.
HTML can be changed in the XSLT template.
And the generated nginx configurations can be updated in the configuration.
XSLT and nginx configurations are generated with the EJS templates.
To check your JS coding standard, run eslint.
npm run eslint
In this repository, there are some tests configurations. They expected Debian/Ubuntu linux with installed nginx-extras
package, symlinked directory tests to the /var/www/static-nginx-gallery/
and pointed host gallery.test
to the nginx. Self-signed certificate is used for SSL configuration.
You can run sudo tests/run-tests
that will try all test configurations one by one.