original templated files
This commit is contained in:
41
roles/nginx-proxy/tasks/main.yml
Normal file
41
roles/nginx-proxy/tasks/main.yml
Normal file
@@ -0,0 +1,41 @@
|
||||
- name: Install Nginx
|
||||
package:
|
||||
name: nginx
|
||||
state: present
|
||||
|
||||
- name: Create web root for landing page
|
||||
file:
|
||||
path: "{{ nginx_webroot }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Deploy landing page HTML
|
||||
copy:
|
||||
content: |
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>Welcome</title></head>
|
||||
<body>
|
||||
<h1>Welcome to Matrix!</h1>
|
||||
<p>Visit <a href="/_matrix">Matrix</a></p>
|
||||
</body>
|
||||
</html>
|
||||
dest: "{{ nginx_webroot }}/index.html"
|
||||
mode: '0644'
|
||||
|
||||
- name: Deploy Nginx config
|
||||
template:
|
||||
src: nginx/default.conf.j2
|
||||
dest: "/etc/nginx/conf.d/{{ matrix_domain }}.conf"
|
||||
mode: '0644'
|
||||
|
||||
- name: Remove default config (optional)
|
||||
file:
|
||||
path: "/etc/nginx/conf.d/default.conf"
|
||||
state: absent
|
||||
|
||||
- name: Restart & enable Nginx
|
||||
service:
|
||||
name: nginx
|
||||
state: restarted
|
||||
enabled: yes
|
||||
36
roles/nginx-proxy/templates/default.conf.j2
Normal file
36
roles/nginx-proxy/templates/default.conf.j2
Normal file
@@ -0,0 +1,36 @@
|
||||
# Landing page (root path)
|
||||
server {
|
||||
listen 80;
|
||||
server_name {{ landing_domain }} {{ matrix_domain }};
|
||||
|
||||
root {{ nginx_webroot }};
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
# Matrix Synapse
|
||||
location /_matrix/ {
|
||||
proxy_pass http://127.0.0.1:8008/_matrix/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Server $host;
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
}
|
||||
|
||||
# Federation (port 8448 usually, but often proxied at /_matrix too)
|
||||
location /_matrix/federation/v1/ {
|
||||
proxy_pass http://127.0.0.1:8448/_matrix/federation/v1/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# Optional: Caddy or Let’s Encrypt ACME
|
||||
}
|
||||
Reference in New Issue
Block a user