nginx-configs/common/website.conf

200 lines
5.7 KiB
Plaintext
Raw Normal View History

2022-07-25 10:55:46 +00:00
add_header Onion-Location http://vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion$request_uri;
2022-10-21 20:40:01 +00:00
add_header X-I2P-Location http://verncceu2kgz54wi7r5jatgmx2mqtsh3knxhiy4m5shescuqtqfa.b32.i2p$request_uri;
2022-09-29 02:25:07 +00:00
root /var/www/website;
index index.html index.php;
2022-07-25 10:55:46 +00:00
ssi on;
2022-09-30 10:58:11 +00:00
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_min_length 1024;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
error_log /var/log/nginx/error.log;
2022-12-13 09:33:39 +00:00
# CGI
location ~ \.php$ {
2022-12-15 15:29:47 +00:00
try_files $uri /$lang$uri /en$uri =404;
2022-12-13 09:33:39 +00:00
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include snippets/fastcgi.conf;
2022-12-21 11:20:28 +00:00
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
2022-12-13 09:33:39 +00:00
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
2022-12-13 09:33:39 +00:00
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
2022-11-27 04:52:19 +00:00
}
2022-12-13 09:33:39 +00:00
location ~ (\.cgi|\.py|\.sh|\.pl|\.lua|\/cgi-bin)$ {
gzip off;
2023-11-30 20:27:10 +00:00
ssi on;
try_files $uri /$lang$uri /en$uri =404;
fastcgi_param SCRIPT_FILENAME $realpath_root$uri;
fastcgi_param POST_STRING $request_body;
2022-12-13 09:33:39 +00:00
fastcgi_pass unix:/run/fcgiwrap.socket;
2022-11-27 04:52:19 +00:00
}
2022-12-13 09:33:39 +00:00
# Main
2022-07-25 10:55:46 +00:00
location / {
2022-12-15 15:30:35 +00:00
if ( -d /var/www/website/$lang) {
rewrite .* /$lang$uri;
}
if ( !-d /var/www/website/$lang) {
rewrite .* /en$uri;
}
}
2022-07-25 10:55:46 +00:00
error_page 403 /en/errors/403;
error_page 404 /en/errors/404;
error_page 503 /en/errors/503;
location /en {
try_files $uri $uri/index.html $uri.html $uri/ @extensionless-php;
error_page 403 /en/errors/403;
error_page 404 /en/errors/404;
error_page 503 /en/errors/503;
2022-07-25 10:55:46 +00:00
}
2022-12-13 09:33:39 +00:00
location /pt-BR {
try_files $uri $uri/index.html $uri.html $uri/ @extensionless-php;
error_page 403 /pt-BR/errors/403;
error_page 404 /pt-BR/errors/404;
error_page 503 /pt-BR/errors/503;
}
2022-07-25 10:55:46 +00:00
2022-12-13 09:33:39 +00:00
location /blog {
alias /var/www/website/blog;
try_files $uri $uri/index.html $uri.html $uri/ @extensionless-php;
index index.html;
2022-09-30 11:04:11 +00:00
}
2022-12-13 09:33:39 +00:00
location /sitemap {
root /sshfs/websiteupdate/website;
try_files $uri $uri.html $uri/ @extensionless-php;
index off;
ssi on;
fancyindex on;
fancyindex_exact_size off;
fancyindex_default_sort date_desc;
fancyindex_time_format "%a, %e %B %Y %I:%M:%S %p";
subs_filter "<style type=\"text/css\">" "";
subs_filter "</syle>" "";
subs_filter "body,html {background:#fff;font-family:\"Bitstream Vera Sans\",\"Lucida Grande\",\"Lucida Sans Unicode\",Lucidux,Verdana,Lucida,sans-serif;}tr:nth-child(even) {background:#f4f4f4;}th,td {padding:0.1em 0.5em;}th {text-align:left;font-weight:bold;background:#eee;border-bottom:1px solid #aaa;}#list {border:1px solid #aaa;width:100%;}a {color:#a33;}a:hover {color:#e33;}" "<!--#include file=\"/nav\"-->";
subs_filter "/sitemap/" "/";
error_page 403 /en/errors/403;
error_page 404 /en/errors/404;
error_page 503 /en/errors/503;
}
2023-11-20 07:03:34 +00:00
#location /status {
# vhost_traffic_status_display;
# vhost_traffic_status_display_format html;
# auth_basic "Administrator Login";
# auth_basic_user_file /var/www/htpasswd;
#}
2022-07-25 10:55:46 +00:00
2022-12-13 09:33:39 +00:00
location ~^/[^u~].*\.(jpg|jpeg|png|gif|ico)$ {
expires 30d;
2022-07-25 10:55:46 +00:00
}
2022-12-13 09:33:39 +00:00
location /.*/errors/.* {
internal;
2022-07-25 10:55:46 +00:00
}
2023-02-02 02:20:20 +00:00
location ~ ^(/media/|/canaries/|/en/finreport/)$ {
fancyindex on;
fancyindex_exact_size off;
fancyindex_default_sort date_desc;
fancyindex_time_format "%a, %e %B %Y %I:%M:%S %p";
}
location /finreport {
alias /var/www/website/en/finreport;
2022-08-07 00:52:49 +00:00
fancyindex on;
fancyindex_exact_size off;
2023-11-30 20:27:10 +00:00
fancyindex_default_sort name_desc;
2022-08-07 00:52:49 +00:00
fancyindex_time_format "%a, %e %B %Y %I:%M:%S %p";
2022-07-25 10:55:46 +00:00
}
2022-12-13 09:33:39 +00:00
# aliases
location /canaries {
alias /var/log/canary;
}
location /media {
alias /var/www/website/media;
}
location /gnuplot {
alias /opt/gnuplot;
}
location /style.css {
alias /var/www/website/style.css;
}
location /LICENSE.txt {
alias /var/www/website/LICENSE.txt;
}
location /tmate.conf {
alias /var/www/website/tmate.conf;
default_type text/plain;
}
location /.tmate.conf {
default_type text/plain;
alias /var/www/website/tmate.conf;
}
location ~ ^/p/(?<user>[\w-]+).asc?$ {
alias /sshfs/home/$user/.pgp.asc;
default_type text/plain;
}
location ~ ^/p/(?<user>[\w-]+).gpg?$ {
alias /sshfs/home/$user/.pgp.gpg;
}
2022-12-15 15:38:54 +00:00
location ~ ^/en/announcements(.html)?$ {
default_type text/html;
alias /var/log/announcements.html;
}
location ~ ^/en/ssi_anno(.shtml)?$ {
default_type text/html;
alias /var/log/ssi_anno.shtml;
}
2022-07-25 10:55:46 +00:00
## users
location ~ ^/(~|u/)(?<user>[\w-]+)(?<user_uri>/.*)?$ {
2022-07-30 18:19:52 +00:00
error_log /var/log/nginx/vern.cc-error.log crit;
root /sshfs/home/$user/public_html;
index index.html index.php index.cgi index.py index.sh index.pl index.lua;
ssi on;
#rewrite ^(.*)$ $scheme://$user.$host redirect;
if ($host = "vern.cc") { rewrite ^(.*)$ $scheme://$user.$host redirect; }
2023-05-23 20:01:44 +00:00
if ($host = "www.vern.cc") { rewrite ^(.*)$ $scheme://$user.vern.cc redirect; }
if ($host = "vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion") { rewrite ^(.*)$ $scheme://$user.$host redirect; }
2023-05-23 20:01:44 +00:00
if ($host = "www.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion") { rewrite ^(.*)$ $scheme://$user.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion redirect; }
2022-07-30 18:19:52 +00:00
try_files $user_uri $user_uri/index.html $user_uri.html $user_uri/ @extensionless-php;
autoindex on;
autoindex_exact_size off;
2022-10-30 19:01:13 +00:00
subs_filter_types text/html text/css text/xml application/javascript text/plain;
2022-10-21 10:32:16 +00:00
subs_filter (((file|virtual|src|href)=|url\()["']?)/([^/]) $1/u/$user/$4 r;
2022-12-21 11:20:28 +00:00
subs_filter "gcdn.vern.cc" "vernlb7gwnsycyt6fw67ak4qx2nn6vimfjxv6xbuwasmb4j6ivva.b32.i2p";
2022-07-31 00:20:43 +00:00
2022-07-30 18:19:52 +00:00
location ~ \.php$ {
fastcgi_pass 192.168.122.30:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
}
2022-07-31 00:20:43 +00:00
2022-07-30 18:19:52 +00:00
location ~ (\.cgi|\.py|\.sh|\.pl|\.lua|\/cgi-bin)$ {
gzip off;
fastcgi_pass 192.168.122.30:9001;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
}
#error_page 404 /404.html;
if (!-d /sshfs/home/$user/public_html) {
return 307 /;
2022-07-30 18:19:52 +00:00
}
2022-07-25 10:55:46 +00:00
}
2022-08-06 18:36:59 +00:00
2023-11-20 07:03:34 +00:00
if ($badagent) {
return 403;
}