85 lines
2.0 KiB
Plaintext
85 lines
2.0 KiB
Plaintext
map $http_upgrade $connection_upgrade {
|
|
default upgrade;
|
|
'' close;
|
|
}
|
|
|
|
server {
|
|
listen 80; # IPv4
|
|
listen [::]:80; #IPv6
|
|
server_name <%= @server_name %>;
|
|
|
|
access_log "/var/log/nginx/mastodon.access.log";
|
|
error_log "/var/log/nginx/mastodon.error.log";
|
|
|
|
location /.well-known {
|
|
root "/var/www/mastodon";
|
|
}
|
|
location / {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl http2; #IPv4
|
|
listen [::]:443 ssl http2; #IPv6
|
|
server_name <%= @server_name %>;
|
|
|
|
access_log "/var/log/nginx/mastodon.access.log";
|
|
error_log "/var/log/nginx/mastodon.error.log";
|
|
|
|
<% if File.exist?(@ssl_cert) &&
|
|
File.exist?(@ssl_key) -%>
|
|
ssl_certificate <%= @ssl_cert %>;
|
|
ssl_certificate_key <%= @ssl_key %>;
|
|
<% end -%>
|
|
|
|
keepalive_timeout 70;
|
|
sendfile on;
|
|
client_max_body_size 0;
|
|
gzip off;
|
|
|
|
root <%= @mastodon_path %>/public;
|
|
|
|
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains";
|
|
|
|
location / {
|
|
try_files $uri @proxy;
|
|
}
|
|
|
|
location @proxy {
|
|
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;
|
|
|
|
proxy_pass_header Server;
|
|
|
|
proxy_pass http://localhost:<%= @puma_port %>;
|
|
proxy_buffering off;
|
|
proxy_redirect off;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection $connection_upgrade;
|
|
|
|
tcp_nodelay on;
|
|
}
|
|
|
|
location /api/v1/streaming {
|
|
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;
|
|
|
|
proxy_pass http://localhost:<%= @streaming_port %>;
|
|
proxy_buffering off;
|
|
proxy_redirect off;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection $connection_upgrade;
|
|
|
|
tcp_nodelay on;
|
|
}
|
|
|
|
error_page 500 501 502 503 504 /500.html;
|
|
}
|