Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Switch to different error page after x time #48

Closed
modem7 opened this issue Jan 24, 2022 · 10 comments · Fixed by #62
Closed

[Feature request] Switch to different error page after x time #48

modem7 opened this issue Jan 24, 2022 · 10 comments · Fixed by #62
Assignees

Comments

@modem7
Copy link
Contributor

modem7 commented Jan 24, 2022

Would be fun if there was a way to switch to a different error page template after x amount of time (e.g. every 24 hours) when it's set to random.

@GoliathLabs
Copy link
Contributor

That would be really nice. So we could see the beauty of each template after some time and users won't be bored with your error pages after a while😄.

@tarampampam
Copy link
Owner

Are you guys serious right now, or is this a joke? 😄

@tarampampam tarampampam self-assigned this Jan 26, 2022
@modem7
Copy link
Contributor Author

modem7 commented Jan 26, 2022

Are you guys serious right now, or is this a joke? 😄

Why not both?! 😂

Nah, for me, I would genuinely like to have different ones without restarting the container cus I'm a lazy lazy sod!

@GoliathLabs
Copy link
Contributor

Same here 😄

@ToshY
Copy link
Contributor

ToshY commented Jan 26, 2022

I don't know if this may help, but you can actually create a config file to use a custom html template (see README). Just generate the files and then mount them to your container . If you add some lovely JS to your custom template I think you can make it a lot more random/fun.

@modem7
Copy link
Contributor Author

modem7 commented Jan 26, 2022

I don't know if this may help, but you can actually create a config file to use a custom html template (see README). Just generate the files and then mount them to your container . If you add some lovely JS to your custom template I think you can make it a lot more random/fun.

Yupper! But in this particular case, I have multiple templates that I would quite like to switch between, rather than a single template until container restart (utilising random).

@AlbanVidal
Copy link

AlbanVidal commented Jan 29, 2022

Hi there,
For start, thanks @tarampampam for those templates, awesome! :)

Like the idea of this Issue, I wished to have different template for each load.
For that, I reorganizes the files (Error_Numbre/Template.html), and used random_index Nginx module.

I used the content of the out directory (see Static error pages), localized in /srv/http-errors on my case, to generate tree Error_Number/Template.html on the /srv/_all-http-errors/ directory:

cd /srv/http-errors
for file in $(find ./ -mindepth 2 -type f); do
    ERR_NO=$(echo $file|sed -E 's/.*\/([0-9]*).*/\1/')
    THEME=$(echo $file|sed -E 's/\.\/([a-z0-9-]*)\/.*/\1/')
    NEW_FILE="${ERR_NO}/${THEME}.html"
    mkdir -p ../_all-http-errors/$ERR_NO/
    cp -v $file ../_all-http-errors/${NEW_FILE}
done
# Output:
# './ghost/400.html' -> '../_all-http-errors/400/ghost.html'
# ...
# './noise/429.html' -> '../_all-http-errors/429/noise.html'

And then, here my Nginx configuration:

# Virtual host:
include /srv/http-errors/error_pages_content.conf;
location ~ /(40[013-9]|41[012368]|429|50[02345])/ {
        root /srv/_all-http-errors;
        allow all;
        random_index on;
}

# /srv/http-errors/error_pages_content.conf
error_page 400 /400/;
error_page 401 /401/;
error_page 403 /403/;
error_page 404 /404/;
error_page 405 /405/;
error_page 407 /407/;
error_page 408 /408/;
error_page 409 /409/;
error_page 410 /410/;
error_page 411 /411/;
error_page 412 /412/;
error_page 413 /413/;
error_page 416 /416/;
error_page 418 /418/;
error_page 429 /429/;
error_page 500 /500/;
error_page 502 /502/;
error_page 503 /503/;
error_page 504 /504/;
error_page 505 /505/;

You can see examples with each error code on those URL:

@tarampampam
Copy link
Owner

@modem7 I can implement a "special theme name" like a random-daily which will change the theme on a randomized only once per day? Or maybe you want to make it more frequent?

@modem7
Copy link
Contributor Author

modem7 commented Feb 1, 2022

@modem7 I can implement a "special theme name" like a random-daily which will change the theme on a randomized only once per day? Or maybe you want to make it more frequent?

That'd be perfect for my needs! Thank you!

@tarampampam
Copy link
Owner

tarampampam commented Feb 1, 2022

v2.6.0 released, now you can use random-daily/random-hourly - themes will be changed in random order once a day/hourly 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants