server {
listen 80;
server_name shizuka.icu;
return 301 https://shizuka.icu/$request_uri;
}
server {
listen 80;
listen 443 ssl http2;
server_name shizuka.icu;
if ($server_port !~ 443){
rewrite ^(/.*)$ https://$host$1/dashboard permanent;
}
ssl_certificate cert/shizuka.icu.pem;
ssl_certificate_key cert/shizuka.icu.key; ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on;
location / {
root /usr/share/nginx/blog/;
try_files $uri $uri/ /index.html;
index index.html;
}
location /status {
stub_status on;
}
location /blog/api/v2/ {
valid_referers shizuka.icu *.shizuka.icu;
if ($invalid_referer) {
return 403;
}
if ($http_user_agent ~* (Scrapy|Curl|HttpClient)) {
return 200;
}
if ($http_user_agent ~"Bytespider|FeedDemon|JikeSpider|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Java|Feedly|UniversalFeedParser|ApacheBench|Microsoft URL Control|Swiftbot|ZmEu|oBot|jaunty|Python-urllib|python-requests|lightDeckReports Bot|YYSpider|DigExt|YisouSpider|HttpClient|MJ12bot|heritrix|EasouSpider|Ezooms|^$" ) {
return 200;
}
if ($request_method !~ ^(GET|HEAD|POST)$) {
return 200;
}
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://shizuka.icu:9420;
}
location /cdn {
valid_referers shizuka.icu *.shizuka.icu;
if ($invalid_referer) {
return 403;
}
proxy_pass https://cdn.bili.icu;
}
location /img/static/ {
valid_referers shizuka.icu *.shizuka.icu;
if ($invalid_referer) {
return 403;
}
proxy_pass https://cdn.bili.icu/;
}
}