bitcoiner.social/ansible/playbooks/host_tasks/gabite.bitcoiner.social/files/nginx/bitcoiner.social.conf

95 lines
2.4 KiB
Plaintext

#
# Ansible managed
#
upstream strfry {
server 127.0.0.1:8000;
}
map $http_accept $is_accept_nostr {
default "0";
"application/nostr+json" "1";
}
# Combine the Upgrade and Accept headers
map "$http_upgrade:$is_accept_nostr" $is_socket_or_nostr {
default "0";
"websocket:0" "1";
"websocket:1" "1";
":1" "1";
}
map "$http_upgrade:$is_accept_nostr" $is_nostr_and_not_socket {
default "0";
"websocket:0" "0";
"websocket:1" "0";
":1" "1";
}
server {
client_max_body_size 0;
include /etc/nginx/acme_bitcoiner.social.conf;
listen 443 ssl;
listen [::]:443 ssl;
access_log off;
location / {
# Intercept NIP-11
if ($is_nostr_and_not_socket = 1) {
return 200 '{"contact":"nostr@bitcoiner.social","description":"A fast, reliable, and up-to-date nostr relay with monitored server availability and nightly off-site backups.","name":"bitcoiner.social","pubkey":"ece3317bf8163930b5dafae50596b740b0608433b78568886a9a712a91a5d59b","software":"git+https://github.com/hoytech/strfry.git","supported_nips":[1,2,4,9,11,12,16,20,22,28,33,40],"version":"0.9.6","icon":"https://bitcoiner.social/favicon.ico"}';
}
# Web Browsers
# if ($is_socket_or_nostr = 0) {
# return 301 https://www.offchain.pub;
# }
proxy_connect_timeout 3m;
proxy_http_version 1.1;
proxy_pass http://strfry;
proxy_read_timeout 3m;
proxy_send_timeout 3m;
proxy_set_header Host $http_host;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
location /static {
alias /var/www/static;
}
location /.well-known/nostr.json {
alias /var/www/.well-known/nostr.json;
add_header Access-Control-Allow-Origin *;
}
location /favicon.ico {
alias /var/www/static/favicon96.png;
}
location = /.well-known/matrix/server {
return 200 '{"m.server":"matrix.bitcoiner.social:443"}'
;
}
location ~ ^(/_matrix|/_synapse/client) {
return 301 https://matrix.bitcoiner.social$request_uri;
}
location /.well-known/lnurlp/ {
proxy_pass http://10.19.21.42:8037;
proxy_set_header Host $http_host;
add_header Access-Control-Allow-Origin *;
}
}