initial commit

This commit is contained in:
pyrschtjag committed 2026-10-02 21:34:01 +04:00
commit 13eace9ce9
219 files changed
+6918

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
---
- name: check nginx config
ansible.builtin.command: nginx -t
changed_when: false
listen: restart nginx
- name: restart nginx systemd service unit
ansible.builtin.systemd_service:
name: nginx
state: restarted
enabled: true
listen: restart nginx
+102
View File
@@ -0,0 +1,102 @@
- name: install dependencies
ansible.builtin.apt:
name:
- curl
- gnupg2
- ca-certificates
- lsb-release
- debian-archive-keyring
state: present
update_cache: true
- name: ensure nginx keyring exists
ansible.builtin.stat:
path: /usr/share/keyrings/nginx-archive-keyring.gpg
register: nginx_keyring
- name: download nginx gpg key
ansible.builtin.get_url:
url: https://nginx.org/keys/nginx_signing.key
dest: /tmp/nginx_signing.key
mode: '0644'
when: not nginx_keyring.stat.exists
- name: dearmor nginx gpg key
ansible.builtin.command:
cmd: gpg --dearmor --yes -o /usr/share/keyrings/nginx-archive-keyring.gpg /tmp/nginx_signing.key
when: not nginx_keyring.stat.exists
- name: ensure gnupg directory exists
ansible.builtin.file:
path: /root/.gnupg
state: directory
mode: '0700'
owner: root
group: root
- name: verify nginx signing key fingerprint
ansible.builtin.command:
cmd: gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
register: nginx_key_check
changed_when: false
check_mode: false
- name: check nginx signing key fingerprint
ansible.builtin.fail:
msg: "nginx signing key fingerprint mismatch! Got: {{ nginx_key_check.stdout }}"
when: "'573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62' not in nginx_key_check.stdout"
- name: add nginx apt repository
ansible.builtin.copy:
dest: /etc/apt/sources.list.d/nginx.list
content: >-
deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg]
https://nginx.org/packages/{{ 'mainline/' if (nginx_use_mainline | default(false)) else '' }}debian
{{ ansible_facts['distribution_release'] }} nginx
owner: root
group: root
mode: "0644"
register: nginx_repo_file
- name: set up repository pinning for nginx
ansible.builtin.copy:
dest: /etc/apt/preferences.d/99nginx
content: |
Package: *
Pin: origin nginx.org
Pin: release o=nginx
Pin-Priority: 900
owner: root
group: root
mode: "0644"
- name: install nginx
ansible.builtin.apt:
name: nginx
state: latest
update_cache: true
- name: remove default config
ansible.builtin.file:
path: /etc/nginx/conf.d/default.conf
state: absent
notify: restart nginx
- name: deploy nginx config
ansible.builtin.template:
src: "{{ inventory_hostname }}/nginx.conf.j2"
dest: "/etc/nginx/nginx.conf"
owner: root
group: root
mode: '0644'
notify: restart nginx
- name: deploy nginx conf.d config
ansible.builtin.template:
src: "{{ item }}"
dest: "/etc/nginx/conf.d/{{ item | basename | regex_replace('\\.j2$', '') }}"
owner: root
group: root
mode: '0644'
loop: "{{ query('ansible.builtin.fileglob', role_path + '/templates/' + inventory_hostname + '/conf.d/*.conf.j2') }}"
notify: restart nginx
@@ -0,0 +1,26 @@
{% for item in dnsmasq %}
{% set short_name = item.name.split('.')[0] %}
server {
listen 127.0.0.1:{{ item.backend_port }} ssl ipv6only=off reuseport;
server_name {{ item.name }};
index index.html;
root {{ placeholders[placeholder].root }};
http2 on;
ssl_certificate /etc/letsencrypt/live/{{ item.name }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ item.name }}/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
client_header_timeout 5m;
keepalive_timeout 5m;
access_log /var/log/nginx/{{ short_name }}_access.log;
error_log /var/log/nginx/{{ short_name }}_error.log;
location {{ xray_xhttp_path }} {
client_max_body_size 0;
grpc_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_body_timeout 5m;
grpc_read_timeout 315;
grpc_send_timeout 5m;
grpc_pass {{ item.socket }};
}
}
{% endfor %}
+42
View File
@@ -0,0 +1,42 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
stream {
log_format proxy '$remote_addr [$time_local] $protocol $status $bytes_sent $bytes_received $session_time "$upstream_addr" "$ssl_preread_server_name"';
access_log /var/log/nginx/stream-access.log proxy;
map $ssl_preread_server_name $backend_name {
{% if telemt_host is defined %}
{{ telemt_host }} {{ telemt_host.split('.')[0] }}_backend;
{% endif %}
{% for item in dnsmasq %}
{{ item.name }} {{ item.name.split('.')[0] }}_backend;
{% endfor %}
default "";
}
{% if telemt_host is defined %}
upstream {{ telemt_host.split('.')[0] }}_backend { server 127.0.0.1:{{ telemt_backend_port }}; }
{% endif %}
{% for item in dnsmasq %}
upstream {{ item.name.split('.')[0] }}_backend { server 127.0.0.1:{{ item.backend_port }}; }
{% endfor %}
server {
listen 443;
ssl_preread on;
proxy_pass $backend_name;
}
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
@@ -0,0 +1,26 @@
{% for item in dnsmasq %}
{% set short_name = item.name.split('.')[0] %}
server {
listen 127.0.0.1:{{ item.backend_port }} ssl ipv6only=off reuseport;
server_name {{ item.name }};
index index.html;
root {{ placeholders[placeholder].root }};
http2 on;
ssl_certificate /etc/letsencrypt/live/{{ item.name }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ item.name }}/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
client_header_timeout 5m;
keepalive_timeout 5m;
access_log /var/log/nginx/{{ short_name }}_access.log;
error_log /var/log/nginx/{{ short_name }}_error.log;
location {{ xray_xhttp_path }} {
client_max_body_size 0;
grpc_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_body_timeout 5m;
grpc_read_timeout 315;
grpc_send_timeout 5m;
grpc_pass {{ item.socket }};
}
}
{% endfor %}
@@ -0,0 +1,42 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
stream {
log_format proxy '$remote_addr [$time_local] $protocol $status $bytes_sent $bytes_received $session_time "$upstream_addr" "$ssl_preread_server_name"';
access_log /var/log/nginx/stream-access.log proxy;
map $ssl_preread_server_name $backend_name {
{% if telemt_host is defined %}
{{ telemt_host }} {{ telemt_host.split('.')[0] }}_backend;
{% endif %}
{% for item in dnsmasq %}
{{ item.name }} {{ item.name.split('.')[0] }}_backend;
{% endfor %}
default "";
}
{% if telemt_host is defined %}
upstream {{ telemt_host.split('.')[0] }}_backend { server 127.0.0.1:{{ telemt_backend_port }}; }
{% endif %}
{% for item in dnsmasq %}
upstream {{ item.name.split('.')[0] }}_backend { server 127.0.0.1:{{ item.backend_port }}; }
{% endfor %}
server {
listen 443;
ssl_preread on;
proxy_pass $backend_name;
}
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
@@ -0,0 +1,64 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
stream {
log_format proxy '$remote_addr [$time_local] $protocol $status $bytes_sent $bytes_received $session_time "$ssl_preread_server_name"';
access_log /var/log/nginx/stream-access.log proxy;
upstream haproxy_http {
server 127.0.0.1:10080;
}
upstream haproxy_backend_pp {
server 127.0.0.1:19443;
}
upstream haproxy_backend_real {
server 127.0.0.1:10443;
}
upstream stunnel_tun0_pp {
server 127.0.0.1:28443;
}
upstream stunnel_tap0_pp {
server 127.0.0.1:28444;
}
upstream stunnel_tun0_backend {
server 127.0.0.1:8443;
}
upstream stunnel_tap0_backend {
server 127.0.0.1:8444;
}
map $ssl_preread_server_name $backend {
liqueur.oyacoi.ru stunnel_tun0_pp;
absinthe.oyacoi.ru stunnel_tap0_pp;
default haproxy_backend_pp;
}
server {
listen {{ ip }}:80;
proxy_pass haproxy_http;
proxy_protocol on;
}
server {
listen {{ ip }}:443;
proxy_pass $backend;
ssl_preread on;
proxy_protocol on;
}
server {
listen 127.0.0.1:19443 proxy_protocol;
set_real_ip_from 127.0.0.1;
proxy_pass haproxy_backend_real;
proxy_protocol on;
}
server {
listen 127.0.0.1:28443 proxy_protocol;
set_real_ip_from 127.0.0.1;
proxy_pass stunnel_tun0_backend;
}
server {
listen 127.0.0.1:28444 proxy_protocol;
set_real_ip_from 127.0.0.1;
proxy_pass stunnel_tap0_backend;
}
}
@@ -0,0 +1,62 @@
#jinja2: trim_blocks: True, lstrip_blocks: True, keep_trailing_newline: True
{% for item in nginx_managed_group | default([]) | sort %}
{% set client = hostvars[item] %}
{% for item_dnsmasq in client.dnsmasq | default([]) %}
{% set short_name = item_dnsmasq.name.split('.')[0] %}
{% if item_dnsmasq.nginx_custom | default(false) %}
{% include "static/" ~ short_name ~ ".conf.j2" ignore missing %}
{% elif item_dnsmasq.upstream_port is defined and client.ip is defined %}
server {
listen 80;
{% if item_dnsmasq.proxy_protocol | default(false) %}
listen 81 proxy_protocol;
set_real_ip_from {{ hostvars["haproxy"]["ip"] }};
real_ip_header proxy_protocol;
{% endif %}
server_name {{ item_dnsmasq.name }};
access_log /var/log/nginx/{{ short_name }}_access.log;
error_log /var/log/nginx/{{ short_name }}_error.log;
{% for cidr in item_dnsmasq.nginx_allow | default([]) %}
allow {{ cidr }};
{% endfor %}
{% if item_dnsmasq.nginx_allow is defined %}
deny all;
{% endif %}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
{% if item_dnsmasq.proxy_protocol | default(false) %}
listen 444 ssl proxy_protocol;
set_real_ip_from {{ hostvars["haproxy"]["ip"] }};
real_ip_header proxy_protocol;
{% endif %}
server_name {{ item_dnsmasq.name }};
ssl_certificate /etc/letsencrypt/live/oyacoi.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/oyacoi.ru/privkey.pem;
access_log /var/log/nginx/{{ short_name }}_access.log;
error_log /var/log/nginx/{{ short_name }}_error.log;
{% for cidr in item_dnsmasq.nginx_allow | default([]) %}
allow {{ cidr }};
{% endfor %}
{% if item_dnsmasq.nginx_allow is defined %}
deny all;
{% endif %}
location / {
proxy_pass http://{{ client.ip }}:{{ item_dnsmasq.upstream_port }};
{% if item_dnsmasq.ws | default(false) %}
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
{% endif %}
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;
}
}
{% endif %}
{% endfor %}
{% endfor %}
@@ -0,0 +1,67 @@
server {
listen 80;
{% if item_dnsmasq.proxy_protocol | default(false) %}
listen 81 proxy_protocol;
set_real_ip_from {{ hostvars['haproxy']['ip'] }};
real_ip_header proxy_protocol;
{% endif %}
server_name {{ item_dnsmasq.name }};
access_log /var/log/nginx/{{ short_name }}_access.log;
error_log /var/log/nginx/{{ short_name }}_error.log;
{% for cidr in item_dnsmasq.nginx_allow | default([]) %}
allow {{ cidr }};
{% endfor %}
{% if item_dnsmasq.nginx_allow is defined %}
deny all;
{% endif %}
location / {
return 302 https://$http_host$request_uri$is_args$query_string;
proxy_pass http://{{ client.ip }}:{{ item_dnsmasq.upstream_port }};
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 3m;
proxy_send_timeout 3m;
proxy_read_timeout 3m;
client_max_body_size 0;
}
}
server {
listen 443 ssl;
{% if item_dnsmasq.proxy_protocol | default(false) %}
listen 444 ssl proxy_protocol;
set_real_ip_from {{ hostvars['haproxy']['ip'] }};
real_ip_header proxy_protocol;
{% endif %}
server_name {{ item_dnsmasq.name }};
ssl_certificate /etc/letsencrypt/live/oyacoi.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/oyacoi.ru/privkey.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
access_log /var/log/nginx/{{ short_name }}_access.log;
error_log /var/log/nginx/{{ short_name }}_error.log;
{% for cidr in item_dnsmasq.nginx_allow | default([]) %}
allow {{ cidr }};
{% endfor %}
{% if item_dnsmasq.nginx_allow is defined %}
deny all;
{% endif %}
location / {
proxy_pass http://{{ client.ip }}:{{ item_dnsmasq.upstream_port }};
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 3m;
proxy_send_timeout 3m;
proxy_read_timeout 3m;
client_max_body_size 0;
}
}
@@ -0,0 +1,51 @@
server {
listen 80;
{% if item_dnsmasq.proxy_protocol | default(false) %}
listen 81 proxy_protocol;
set_real_ip_from {{ hostvars['haproxy']['ip'] }};
real_ip_header proxy_protocol;
{% endif %}
server_name {{ item_dnsmasq.name }};
access_log /var/log/nginx/{{ short_name }}_access.log;
error_log /var/log/nginx/{{ short_name }}_error.log;
{% for cidr in item_dnsmasq.nginx_allow | default([]) %}
allow {{ cidr }};
{% endfor %}
{% if item_dnsmasq.nginx_allow is defined %}
deny all;
{% endif %}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
{% if item_dnsmasq.proxy_protocol | default(false) %}
listen 444 ssl proxy_protocol;
set_real_ip_from {{ hostvars['haproxy']['ip'] }};
real_ip_header proxy_protocol;
{% endif %}
server_name {{ item_dnsmasq.name }};
ssl_certificate /etc/letsencrypt/live/oyacoi.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/oyacoi.ru/privkey.pem;
access_log /var/log/nginx/{{ short_name }}_access.log;
error_log /var/log/nginx/{{ short_name }}_error.log;
{% for cidr in item_dnsmasq.nginx_allow | default([]) %}
allow {{ cidr }};
{% endfor %}
{% if item_dnsmasq.nginx_allow is defined %}
deny all;
{% endif %}
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass https://{{ client.ip }}:{{ item_dnsmasq.upstream_port }};
proxy_buffering off;
client_max_body_size 0;
proxy_connect_timeout 3600s;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
send_timeout 3600s;
}
}
@@ -0,0 +1,46 @@
server {
listen 443 ssl;
{% if item_dnsmasq.proxy_protocol | default(false) %}
listen 444 ssl proxy_protocol;
set_real_ip_from {{ hostvars['haproxy']['ip'] }};
real_ip_header proxy_protocol;
{% endif %}
server_name {{ item_dnsmasq.name }};
ssl_certificate /etc/letsencrypt/live/oyacoi.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/oyacoi.ru/privkey.pem;
access_log /var/log/nginx/{{ short_name }}_access.log;
error_log /var/log/nginx/{{ short_name }}_error.log;
set $prosody_url "http://{{ client.ip }}:{{ item_dnsmasq.upstream_port }}";
{% for cidr in item_dnsmasq.nginx_allow | default([]) %}
allow {{ cidr }};
{% endfor %}
{% if item_dnsmasq.nginx_allow is defined %}
deny all;
{% endif %}
location /xmpp-websocket {
proxy_pass $prosody_url/xmpp-websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 900s;
}
location /http-bind {
proxy_pass $prosody_url/http-bind;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
tcp_nodelay on;
}
location /.well-known/host-meta {
proxy_pass $prosody_url/.well-known/host-meta;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location / {
return 444;
}
}
@@ -0,0 +1,43 @@
server {
listen 80;
server_name {{ item_dnsmasq.name }};
access_log /var/log/nginx/{{ short_name }}_access.log;
error_log /var/log/nginx/{{ short_name }}_error.log;
{% for cidr in item_dnsmasq.nginx_allow | default([]) %}
allow {{ cidr }};
{% endfor %}
{% if item_dnsmasq.nginx_allow is defined %}
deny all;
{% endif %}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name {{ item_dnsmasq.name }};
ssl_certificate /etc/letsencrypt/live/oyacoi.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/oyacoi.ru/privkey.pem;
access_log /var/log/nginx/{{ short_name }}_access.log;
error_log /var/log/nginx/{{ short_name }}_error.log;
{% for cidr in item_dnsmasq.nginx_allow | default([]) %}
allow {{ cidr }};
{% endfor %}
{% if item_dnsmasq.nginx_allow is defined %}
deny all;
{% endif %}
location / {
proxy_pass http://{{ client.ip }}:{{ item_dnsmasq.upstream_port }};
proxy_buffering off;
proxy_request_buffering off;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
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;
}
}
@@ -0,0 +1,32 @@
server {
listen 443 ssl;
{% if item_dnsmasq.proxy_protocol | default(false) %}
listen 444 ssl proxy_protocol;
set_real_ip_from {{ hostvars['haproxy']['ip'] }};
real_ip_header proxy_protocol;
{% endif %}
server_name {{ item_dnsmasq.name }};
ssl_certificate /etc/letsencrypt/live/oyacoi.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/oyacoi.ru/privkey.pem;
access_log /var/log/nginx/{{ short_name }}_access.log;
error_log /var/log/nginx/{{ short_name }}_error.log;
{% for cidr in item_dnsmasq.nginx_allow | default([]) %}
allow {{ cidr }};
{% endfor %}
{% if item_dnsmasq.nginx_allow is defined %}
deny all;
{% endif %}
location / {
proxy_pass http://{{ client.ip }}:{{ item_dnsmasq.upstream_port }};
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 https;
client_max_body_size 1024M;
proxy_request_buffering off;
proxy_buffering off;
proxy_connect_timeout 90s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
}
}
+20
View File
@@ -0,0 +1,20 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
@@ -0,0 +1,26 @@
{% for item in dnsmasq %}
{% set short_name = item.name.split('.')[0] %}
server {
listen 127.0.0.1:{{ item.backend_port }} ssl ipv6only=off reuseport;
server_name {{ item.name }};
index index.html;
root /var/www/html/dist/;
http2 on;
ssl_certificate /etc/letsencrypt/live/{{ item.name }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ item.name }}/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
client_header_timeout 5m;
keepalive_timeout 5m;
access_log /var/log/nginx/{{ short_name }}_access.log;
error_log /var/log/nginx/{{ short_name }}_error.log;
location {{ xray_xhttp_path }} {
client_max_body_size 0;
grpc_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_body_timeout 5m;
grpc_read_timeout 315;
grpc_send_timeout 5m;
grpc_pass {{ item.socket }};
}
}
{% endfor %}
@@ -0,0 +1,42 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
stream {
log_format proxy '$remote_addr [$time_local] $protocol $status $bytes_sent $bytes_received $session_time "$upstream_addr" "$ssl_preread_server_name"';
access_log /var/log/nginx/stream-access.log proxy;
map $ssl_preread_server_name $backend_name {
{% if telemt_host is defined %}
{{ telemt_host }} {{ telemt_host.split('.')[0] }}_backend;
{% endif %}
{% for item in dnsmasq %}
{{ item.name }} {{ item.name.split('.')[0] }}_backend;
{% endfor %}
default "";
}
{% if telemt_host is defined %}
upstream {{ telemt_host.split('.')[0] }}_backend { server 127.0.0.1:{{ telemt_backend_port }}; }
{% endif %}
{% for item in dnsmasq %}
upstream {{ item.name.split('.')[0] }}_backend { server 127.0.0.1:{{ item.backend_port }}; }
{% endfor %}
server {
listen 443;
ssl_preread on;
proxy_pass $backend_name;
}
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}