Compare commits

...

2 Commits

Author SHA1 Message Date
ad23896e5f Merge pull request 'Handles domain that is not explicitly configured' (#1) from nginx-default-server into master
Reviewed-on: marito/Lenvi#1

- Tested on WSL2 Ubuntu 24.04: functions as expected. Domains listed in the hosts file but not configured in Nginx correctly return a 404 error.
2025-06-17 05:46:28 +00:00
bab929047e Handles domain that is not explicitly configured 2025-06-17 13:36:46 +08:00
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,11 @@
# This is the default catch-all server.
# It handles any request for a domain that is not explicitly configured.
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
# Return a 404 Not Found error.
return 404;
}

View File

@ -14,4 +14,13 @@
ansible.builtin.file:
path: /etc/nginx/sites-enabled/default
state: absent
notify: Reload Nginx
- name: "Create a default catch-all server block"
ansible.builtin.copy:
src: 00-default-catch-all.conf
dest: /etc/nginx/conf.d/00-default-catch-all.conf
owner: root
group: root
mode: '0644'
notify: Reload Nginx