Skip to content

Commit 7412c4c

Browse files
zhquansduenas
authored andcommitted
[nginx] Add default virtual host configuration
Serve a 404 Not Found page when the server name is not configured. Signed-off-by: Quan Zhou <quan@bitergia.com>
1 parent f211fcf commit 7412c4c

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed
46.4 KB
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>404 Not Found</title>
5+
</head>
6+
<body>
7+
<div style="text-align: center;">
8+
<img src="bitergia-logo.png" alt="Bitergia" width="200" height="220">
9+
<h1>Oops! Page Not Found</h1>
10+
<p>Sorry, the page you're looking for doesn't exist.</p>
11+
</div>
12+
</body>
13+
</html>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
server {
2+
listen 80 default_server;
3+
server_name _;
4+
5+
error_page 404 /custom_404.html;
6+
7+
location = /custom_404.html {
8+
root /etc/nginx/conf.d;
9+
internal;
10+
}
11+
}
12+
13+
server {
14+
listen 443 default_server;
15+
server_name _;
16+
17+
error_page 404 /custom_404.html;
18+
19+
location = /custom_404.html {
20+
root /etc/nginx/conf.d;
21+
internal;
22+
}
23+
24+
location /bitergia-new-logo.png {
25+
root /etc/nginx/conf.d;
26+
}
27+
}

ansible/roles/nginx/tasks/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@
9292
loop_control:
9393
loop_var: instance
9494

95+
- name: Copy the default host configuration files
96+
copy:
97+
src: "{{ item }}"
98+
dest: "{{ nginx_virtualhosts_workdir }}/{{ item }}"
99+
with_items:
100+
- bitergia-logo.png
101+
- custom_404.html
102+
- default.conf
103+
95104
- name: Start NGINX container with virtualhost(s)
96105
docker_container:
97106
name: "{{ nginx_docker_container }}"

0 commit comments

Comments
 (0)