项目作者: andreasscherbaum

项目描述 :
Rickrolling for 404 requests
高级语言:
项目地址: git://github.com/andreasscherbaum/ansible-rickrolling.git
创建时间: 2020-05-19T16:26:09Z
项目社区:https://github.com/andreasscherbaum/ansible-rickrolling

开源协议:

下载


ansible-rickrolling

Rickrolling for 404 requests

Description

Every webserver log is spammed with 404 (Not Found) requests. The setup in this repository allows to redirect such requests to the famous Rickrolling Video.

Idea inspired by this Tweet.

Ansible

To ease configuration and deployment, Ansible is used and generates a configuration file. The input URLs (the 404) are listed in two files:

  • redirect.txt: simple URLs, including the full request, no regexp required
  • redirectmatch.txt: complex URLs, a regexp is required to match the URL

The “Redirect” and “RedirectMatch” names are based on the Apache2 mod_alias Module. It is not necessary to enable the more complex mod_rewrite module for simple redirects.

Apache2

In your vhosts configuration, all you have to do is include the rickrolling.conf:

  1. Include "/etc/apache2/rickrolling.conf"

Data Source

Two different ways to load the data files into Ansible:

Local Copy

Check out this repository and point your Playbook to the redirect.txt and redirectmatch.txt files.

  1. - name: Read block lists and set config
  2. set_fact:
  3. rickrolling_destination: "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  4. rickrolling_redirect: "{{ lookup('file', '/path/to/ansible-rickrolling/redirect.txt').splitlines() }}"
  5. rickrolling_redirectmatch: "{{ lookup('file', '/path/to/ansible-rickrolling/redirectmatch.txt').splitlines() }}"
  6. - name: Install block list
  7. template:
  8. src: "/path/to/ansible-rickrolling/apache2.conf"
  9. dest: "/etc/apache2/rickrolling.conf"
  10. owner: www-data
  11. group: www-data
  12. mode: 0755
  13. notify:
  14. - restart apache2

Online Copy

Use the URI module to download a copy of the files during deployment.

Note: Your Ansible host must be able to reach GitHub during deployment.

  1. - name: Fetch redirect.txt
  2. uri:
  3. url: https://raw.githubusercontent.com/andreasscherbaum/ansible-rickrolling/master/redirect.txt
  4. return_content: yes
  5. register: rickrolling_src_redirect
  6. - name: Fetch redirect.txt
  7. uri:
  8. url: https://raw.githubusercontent.com/andreasscherbaum/ansible-rickrolling/master/redirectmatch.txt
  9. return_content: yes
  10. register: rickrolling_src_redirectmatch
  11. - name: Import block lists and set config
  12. set_fact:
  13. rickrolling_destination: "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  14. rickrolling_redirect: "{{ rickrolling_src_redirect.content.splitlines() }}"
  15. rickrolling_redirectmatch: "{{ rickrolling_src_redirectmatch.content.splitlines() }}"
  16. - name: Install block list
  17. template:
  18. src: "/path/to/ansible-rickrolling/apache2.conf"
  19. dest: "/etc/apache2/rickrolling.conf"
  20. owner: www-data
  21. group: www-data
  22. mode: 0755
  23. notify:
  24. - restart apache2

Support

You can send PRs with additional URLs, or config examples for other webservers.