# The requested handler 'Reload nginx' was not found

**URL:** <https://forum.ansible.com/t/the-requested-handler-reload-nginx-was-not-found/7617>\
**Category:** Get Help\
**Tags:** playbook\
**Created:** [August 3, 2024, 5:13pm UTC](https://forum.ansible.com/t/the-requested-handler-reload-nginx-was-not-found/7617 "2024-08-03T17:13:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![micneu](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@micneu](https://forum.ansible.com/u/micneu)\
**Post date:** [August 3, 2024, 5:13pm UTC](https://forum.ansible.com/t/the-requested-handler-reload-nginx-was-not-found/7617/1 "2024-08-03T17:13:23Z")

</div>

- when I run my playbook I get an error message and the process is aborted  
`ERROR! The requested handler 'Reload nginx' was not found in either the main handlers list nor in the listening handlers list`
- Include the version(s) of the relevant software tools, libraries, collections etc

```auto
 % ansible --version
ansible [core 2.15.9]
  config file = /Users/micneu/Library/Mobile Documents/com~apple~CloudDocs/ansible_project/ansible.cfg
  configured module search path = ['/usr/share/ansible']
  ansible python module location = /Users/micneu/Library/Python/3.9/lib/python/site-packages/ansible
  ansible collection location = /Users/micneu/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/micneu/Library/Python/3.9/bin/ansible
  python version = 3.9.6 (default, Mar 29 2024, 10:51:09) [Clang 15.0.0 (clang-1500.3.9.4)] (/Applications/Xcode.app/Contents/Developer/usr/bin/python3)
  jinja version = 3.1.3
  libyaml = True

```

- Include relevant logs from the issue  
I don’t have any logs, if so how should I find them?
- Set at least one tag (the experts follow the tags, so the right people will find you if you tag)

```auto
1. my directory structure
nginx-reverse-proxies
| ____ tasks
| | ____ nginx.yml
| | ____ nginx2.yml
| | ____ goip.yml
| | ____ sys_limit.yml
| | ____ update_nginx_ips_2.yml
| | ____ docker.yml
| | ____ librespeed.yml
| | ____ le.yml
| ____.DS_Store
| ____ files
| | ____.DS_Store
| | ____ goip.service
| | ____ allowed-domain.list
| | ____ update_nginx_ips_2.sh
| | ____ aarch64
| | | ____ ipify-api
| | ____ x86_64
| | | ____ ipify-api
| ____ templates
| | ____ nginx-proxy.conf.j2
| | ____ linux.service.j2
| | ____ nginx-ssl.conf.j2
| | ____ nginx-site.conf.j2
| | ____ nginx-main.conf.j2
| ____ handlers
| | ____ main.yml
| ____ nginx-setup.yml

```

in the handlers directory  
I have according to my understanding

```auto
---
- name: Reload nginx
  ansible.builtin.service:
    name: "nginx.service"
    state: reloaded

- name: Restart nginx
  ansible.builtin.service:
    name: "nginx.service"
    state: restarted

- name: Reload systemd
  ansible.builtin.systemd:
    daemon_reload: true

```

what is wrong with my code?  
nginx2.yml

```auto
---
- name: Install Nginx
  ansible.builtin.apt:
    name: nginx
    state: present

- name: Install PHP and PHP-FPM
  ansible.builtin.apt:
    name: "{{ item }}"
    state: present
  loop:
    - php-fpm
    - php-mysql # Add any other PHP extensions you need

- name: Ensure webroot directory exists
  ansible.builtin.file:
    path: "{{ webroot_path }}"
    state: directory
    owner: root
    group: root
    mode: '0644'

- name: Create main Nginx configuration
  ansible.builtin.template:
    src: templates/nginx-main.conf.j2
    dest: /etc/nginx/sites-available/reverse-proxy.conf
    owner: root
    group: root
    mode: '0644'
  notify:
    - Restart nginx

- name: Enable main Nginx configuration
  ansible.builtin.file:
    src: /etc/nginx/sites-available/reverse-proxy.conf
    dest: /etc/nginx/sites-enabled/reverse-proxy.conf
    state: link
 notify:
   - Reload nginx

- name: Remove default Nginx configuration
  ansible.builtin.file:
    path: /etc/nginx/sites-enabled/default
    state: absent
 notify:
   - Reload nginx

- name: Create SSL configuration file
  ansible.builtin.template:
    src: templates/nginx-ssl.conf.j2
    dest: /etc/nginx/snippets/ssl-params.conf
    owner: root
    group: root
    mode: '0644'
  when: use_letsencrypt

- name: Create individual site configuration files
  ansible.builtin.template:
    src: templates/nginx-site.conf.j2
    dest: "/etc/nginx/sites-available/{{ item.name }}.conf"
    owner: root
    group: root
    mode: '0644'
  loop: "{{ site_configs }}"
  notify:
    - Reload nginx

- name: Enable individual site configurations
  ansible.builtin.file:
    src: "/etc/nginx/sites-available/{{ item.name }}.conf"
    dest: "/etc/nginx/sites-enabled/{{ item.name }}.conf"
    state: link
  loop: "{{ site_configs }}"
 notify:
   - Reload nginx

```

---

<div class="post-metadata">

**Author:** ![bvitnik](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bvitnik/32/4132_2.png) [@bvitnik](https://forum.ansible.com/u/bvitnik)\
**Post date:** [August 4, 2024, 12:15am UTC](https://forum.ansible.com/t/the-requested-handler-reload-nginx-was-not-found/7617/2 "2024-08-04T00:15:22Z")

</div>

Hi Micha. Is `nginx-reverse-proxies` a role? Also, where is your playbook?

---

<div class="post-metadata">

**Author:** ![micneu](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@micneu](https://forum.ansible.com/u/micneu)\
**Post date:** [August 4, 2024, 1:15am UTC](https://forum.ansible.com/t/the-requested-handler-reload-nginx-was-not-found/7617/3 "2024-08-04T01:15:48Z")

</div>

yes, that is a role, sorry I forgot to mention it (I’m new to the topic)

```auto
nginx-setup.yml
---
- name: Setup Nginx reverse proxy, static website, and PHP with Let's Encrypt SSL
  hosts: webserver
  gather_facts: true
  become: true
  # variablen definieren
  vars:
    use_letsencrypt: false # Set to false to disable Let's Encrypt
    enable_https_redirect: false # Set to false to disable HTTP to HTTPS redirect
    domains:
      - domain.tld
      - www.domain.tld
      - film.domain.tld
      - ip.domain.tld
      - speedtest.domain.tld
      - adventskalender.domain.tld
      - bilder.domain.tld
    email: www2@domain.tld
    webroot_path: /var/www/html
    site_configs:
# - name: "app1"
# server_name: "app1.example.com"
# proxy_pass: "http://localhost:8081"
# access_log: "/var/log/nginx/app1_access.log"
# error_log: "/var/log/nginx/app1_error.log"
# type: "proxy" # "proxy", "static", or "php"
# root: "/var/www/app1" # only used if type is "static" or "php"
# custom_include: "/etc/nginx/includes/app1_custom.conf" # optional
# deny_ips: [] # optional
      - name: "film"
        server_name: "film2.domain.tld"
        proxy_pass: "http://192.168.3.249:8899"
        access_log: "/var/log/nginx/film_access.log"
        error_log: "/var/log/nginx/film_error.log"
        type: "proxy" # "proxy", "static", or "php"
        root: "" # only used if type is "static" or "php"
        custom_include: "/etc/nginx/allowed-ips-from-domains-active[.]conf" # optional
        deny_ips: ["all"] # optional
# - name: "film"
# server_name: "film.domain.tld"
# proxy_pass: "http://127.0.0.1:8899"
# access_log: "/var/log/nginx/film_access.log"
# error_log: "/var/log/nginx/film_error.log"
# type: "proxy" # "proxy", "static", or "php"
# root: "" # only used if type is "static" or "php"
# custom_include: "/etc/nginx/allowed-ips-from-domains-active.conf" # optional
# deny_ips: ["all"] # optional
      - name: "ip"
        server_name: "ip2.domain.tld"
        proxy_pass: "http://127.0.0.1:8777"
        access_log: "/var/log/nginx/ip_access.log"
        error_log: "/var/log/nginx/ip_error.log"
        type: "proxy" # "proxy", "static", or "php"
        root: "" # only used if type is "static" or "php"
        custom_include: "" # optional
        deny_ips: [] # optional
      - name: "speedtest"
        server_name: "speedtest2.domain.tld"
        proxy_pass: "http://127.0.0.1:8888"
        access_log: "/var/log/nginx/speedtest_access.log"
        error_log: "/var/log/nginx/speedtest_error.log"
        type: "proxy" # "proxy", "static", or "php"
        root: "/var/www/app2" # only used if type is "static" or "php"
        custom_include: "" # optional
        deny_ips: [] # optional
      - name: "adventskalender"
        server_name: "adventskalender2.domain.tld"
        proxy_pass: ""
        access_log: "/var/log/nginx/adventskalender_access.log"
        error_log: "/var/log/nginx/adventskalender_error.log"
        type: "static" # "proxy", "static", or "php"
        root: "/var/www/adventskalender/html" # only used if type is "static" or "php"
        custom_include: "" # optional
        deny_ips: [] # optional
      - name: "www"
        server_name: "www2.domain.tld"
        proxy_pass: "http://127.0.0.1:8888"
        access_log: "/var/log/nginx/www_access.log"
        error_log: "/var/log/nginx/www_error.log"
        type: "static" # "proxy", "static", or "php"
        root: "/var/www/octopress" # only used if type is "static" or "php"
        custom_include: "" # optional
        deny_ips: [] # optional
      - name: "bilder"
        server_name: "bilder2.domain.tld"
        proxy_pass: ""
        access_log: "/var/log/nginx/bilder_access.log"
        error_log: "/var/log/nginx/bilder_error.log"
        type: "static" # "proxy", "static", or "php"
        root: "/var/www/bilder" # only used if type is "static" or "php"
        custom_include: "" # optional
        deny_ips: [] # optional
  # /variablen definieren
  tasks:
# - name: Execute the command (set ulimit)
# ansible.builtin.shell: ulimit -n 4096; ulimit -Hn 16384

    - name: Add a line "export SYSTEMD_EDITOR=vim" to /etc/profile
      ansible.builtin.lineinfile:
        path: /etc/profile
        line: export SYSTEMD_EDITOR=vim
        create: true
        owner: root
        group: root
        mode: '0644'

    # verzeichnisse anlegen
    - name: Ensure directories exist with correct permissions
      ansible.builtin.file:
        path: "{{ item.path }}"
        state: directory
        owner: "{{ item.owner }}"
        group: "{{ item.group }}"
        mode: "{{ item.mode }}"
      loop:
        - { path: "/var/www/adventskalender", owner: "www-data", group: "adm", mode: "0755" }
        - { path: "/var/www/octopress", owner: "www-data", group: "adm", mode: "0755" }
        - { path: "/var/www/bilder", owner: "www-data", group: "adm", mode: "0755" }
        - { path: "/etc/nginx", owner: "www-data", group: "adm", mode: "0755" }
        - { path: "/var/log/nginx", owner: "www-data", group: "adm", mode: "0755" }

    - name: Include update_nginx_ips_2
      ansible.builtin.include_tasks: tasks/update_nginx_ips_2.yml

    - name: Include goip
      ansible.builtin.include_tasks: tasks/goip.yml

    - name: Include docker
      ansible.builtin.include_tasks: tasks/docker.yml

    - name: Include docker librespeed
      ansible.builtin.include_tasks: tasks/librespeed.yml

    - name: Include nginx2
      ansible.builtin.include_tasks: tasks/nginx2.yml

    - name: Include le
      ansible.builtin.include_tasks: tasks/le.yml

```
