uechi.io/nginx.conf

91 lines
2.3 KiB
Nginx Configuration File
Raw Normal View History

2021-06-08 16:50:52 +09:00
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
keepalive_timeout 65;
2022-02-05 13:41:25 +09:00
server {
2022-03-04 15:03:48 +09:00
server_name uechi.io;
2021-06-08 16:50:52 +09:00
listen 80;
root /var/www/html;
error_page 404 /404.html;
2022-12-24 03:20:02 +09:00
# Matix/Synapse
# https://matrix-org.github.io/synapse/develop/reverse_proxy.html
# https://matrix-org.github.io/synapse/latest/setup/installation.html#client-well-known-uri
location ~ ^(/_matrix|/_synapse/client) {
# note: do not add a path (even a single /) after the port in `proxy_pass`,
# otherwise nginx will canonicalise the URI and cause signature verification
# errors.
# https://stackoverflow.com/a/54719226/2276646
resolver 127.0.0.11 valid=30s;
set $upstream_synapse synapse;
proxy_pass http://$upstream_synapse:8008;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
# Nginx by default only allows file uploads up to 1M in size
# Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
client_max_body_size 50M;
}
location /.well-known/matrix/client {
return 200 '{"m.homeserver": {"base_url": "https://matrix.uechi.io"}}';
default_type application/json;
add_header Access-Control-Allow-Origin *;
}
location /.well-known/matrix/server {
return 200 '{"m.server": "matrix.uechi.io:443"}';
default_type application/json;
add_header Access-Control-Allow-Origin *;
}
2021-06-08 16:50:52 +09:00
location /404.html {
internal;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
index index.html;
2022-06-25 16:00:17 +09:00
try_files $uri $uri.html $uri/index.html @fallback;
2021-06-08 16:50:52 +09:00
}
location = / {
if ($http_user_agent ~ curl) {
rewrite / /TERMINAL last;
}
}
2022-06-25 16:00:17 +09:00
location @fallback {
root /var/www/html/_;
try_files $uri $uri.html $uri/index.html =404;
}
2021-06-08 16:50:52 +09:00
}
2022-03-04 15:03:48 +09:00
server {
listen 80;
server_name www.uechi.io;
2022-06-02 19:15:55 +09:00
return 301 $scheme://uechi.io$request_uri;
2022-03-04 15:03:48 +09:00
}
2021-06-08 16:50:52 +09:00
}