mirror of
https://github.com/thewesker/greptweet.git
synced 2025-12-20 12:11:05 -05:00
This commit is contained in:
21
nginx.conf
21
nginx.conf
@@ -10,6 +10,7 @@ http {
|
|||||||
sendfile on;
|
sendfile on;
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_vary on;
|
gzip_vary on;
|
||||||
|
# Some things are gzipped on the fly, but tweets.txt.gz is kept gzipped on disk to save disk space
|
||||||
gzip_types application/x-javascript text/css application/javascript application/json;
|
gzip_types application/x-javascript text/css application/javascript application/json;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
@@ -17,24 +18,24 @@ http {
|
|||||||
server_name greptweet.com;
|
server_name greptweet.com;
|
||||||
root /srv/http;
|
root /srv/http;
|
||||||
charset utf-8;
|
charset utf-8;
|
||||||
access_log /srv/http/u/greptweet.access.log;
|
access_log /var/log/nginx/greptweet.access.log;
|
||||||
error_log /srv/http/u/greptweet.error.log;
|
error_log /var/log/nginx/greptweet.error.log;
|
||||||
error_page 403 =303 /404.php;
|
error_page 403 =303 /404.php;
|
||||||
error_page 404 /404.php;
|
error_page 404 = /404.php;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
index index.php index.html;
|
index index.php index.html;
|
||||||
rewrite ^/f/(.*)$ /create.php?id=$1 last;
|
rewrite ^/f/(.*)$ /create.php?id=$1 last;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ \.(gz)$ {
|
location ~ \.(gz)$ {
|
||||||
add_header Content-Encoding gzip;
|
add_header Content-Encoding gzip;
|
||||||
gzip off;
|
gzip off;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ \.(txt)$ {
|
location ~ \.(txt)$ {
|
||||||
rewrite ^/u/(.*)/ /u/$1/$1.txt.gz last;
|
rewrite ^/u/(.*)/ /u/$1/$1.txt.gz last;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~* \.(svg|css|js)$ {
|
location ~* \.(svg|css|js)$ {
|
||||||
expires 7d;
|
expires 7d;
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
if (preg_match('#^/u/#', $_SERVER["REQUEST_URI"])) {
|
if (preg_match('#^/u/#', $_SERVER["REQUEST_URI"])) {
|
||||||
$username = basename($_SERVER["REQUEST_URI"]);
|
$username = basename($_SERVER["REQUEST_URI"]);
|
||||||
if ((!empty($username)) && (strlen($username < 16)) && preg_match('/^[A-Za-z0-9_]+$/', $username)) {
|
if ((!empty($username)) && (strlen($username < 16)) && preg_match('/^[A-Za-z0-9_]+$/', $username)) {
|
||||||
header("Location:http://" . $_SERVER["HTTP_HOST"] . "/f/" . $username);
|
header("HTTP/1.1 303 See Other");
|
||||||
die();
|
header("Location:http://" . $_SERVER["HTTP_HOST"] . "/f/" . strtolower($username));
|
||||||
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user