Skip to content

Instantly share code, notes, and snippets.

@zh99998
Last active December 12, 2015 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zh99998/4710849 to your computer and use it in GitHub Desktop.
Save zh99998/4710849 to your computer and use it in GitHub Desktop.
mycard-web-front
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
server_name my-card.in;
ssl_certificate ssl.my-card.in.crt;
ssl_certificate_key ssl.my-card.in.key;
charset utf-8;
add_header "X-UA-Compatible" "IE=edge,chrome=1";
location /login {
rewrite (.*) https://github.com/mycard/mycard/wiki/mycard:%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98? redirect;
}
#card_images
rewrite ^/images/cards/ygocore/(.+)\.jpg$ http://images.my-card.in/$1.jpg redirect;
rewrite ^/cards/\d(\d+)\.png$ http://images.my-card.in/$1.jpg redirect;
#download & update
location /mycard/update.json {
proxy_pass http://update.my-card.in/update.php;
}
location /mycard/download {
proxy_pass http://update.my-card.in/download.php;
}
location /mycard/download.url {
proxy_pass http://update.my-card.in/download.php?show_url=true;
}
location /mycard/updates {
rewrite ^(.*)$ http://downloads.my-card.in/updates/ redirect;
}
location /mycard/downloads {
rewrite ^(.*)$ http://downloads.my-card.in/downloads/ redirect;
}
#users
location /users {
proxy_redirect http://users.my-card.in/ https://my-card.in/;
proxy_pass http://users.my-card.in;
}
location /register {
#rewrite .* https://github.com/zh99998/mycard/wiki/%E7%94%A8%E6%88%B7 redirect;
proxy_pass http://users.my-card.in/users/sign_up/;
}
#avatar
location /system {
proxy_pass http://users.my-card.in;
}
#show_room
rewrite ^/rooms/(.*@)?[\d\.]+\:\d+ /rooms/show.html last;
#cards_database
rewrite ^/cards(_[\w\-]+)?(?:\.json)?(?:\?(.*))?$ /cards_database/cards$1?apiKey=508e5726e4b0c54ca4492ead&l=0$arg_l&$2 last;
location /cards_database/ {
proxy_pass https://api.mongolab.com/api/1/databases/mycard/collections/;
}
rewrite ^/cards/([^\.]*)$ http://www.ourocg.cn/S.aspx?key="$1" redirect;
#decks
location /decks/new.ydk {
proxy_pass http://api.my-card.in/decks.php;
}
rewrite ^/decks/new$ /decks/new/index.html last;
#puzzles
location /puzzles/ {
if ($ssl_protocol) {
rewrite ^(.*)$ http://$host$1 redirect;
}
proxy_pass http://mycard.github.io/ygopro-PuzzleMaker/;
}
location /singles/new.lua {
proxy_pass http://api.my-card.in/singles.php;
}
#duels
location /duels/new.yrp {
proxy_pass http://api.my-card.in/duels.php;
}
location /cards/new.png {
proxy_pass http://phoenix.my-card.in/index.php;
}
location /cards/0.png {
proxy_pass http://mycard.github.io/ygopro-web/img/textures/unknown.jpg;
}
#replays
location ~ ^/replays/(\w+)$ {
proxy_pass http://mycard.github.io/ygopro-web/show.html?fucknginx=$1;
}
location ~ ^/replays/(\w+)\.(\w+)$ {
add_header Access-Control-Allow-Origin *; #CORs widely open, for debug.
if ($request_method = 'OPTIONS') {
return 204;
}
proxy_pass http://api.my-card.in/replays_show.php?id=$1&format=$2;
}
location ~ ^/replays/(\w+)/comments {
add_header Access-Control-Allow-Origin *; #CORs widely open, for debug.
if ($request_method = 'OPTIONS') {
return 204;
}
if ($request_method = GET) {
proxy_pass http://api.my-card.in/replay_comments_show.php?replay_id=$1;
}
if ($request_method = POST) {
proxy_pass http://api.my-card.in/replay_comments_create.php?replay_id=$1;
}
}
location /replays {
if ($request_method = GET){
rewrite ^/replays$ /replays/ redirect;
rewrite /replays/(.*) /ygopro-web/$1;
}
add_header Access-Control-Allow-Origin *; #CORs widely open, for debug.
if ($request_method = 'OPTIONS') {
return 204;
}
if ($request_method = POST){
proxy_pass http://api.my-card.in/replays_create.php?fucknginx=$1;
}
}
location /replays.json {
proxy_pass http://api.my-card.in/replays_index.php;
}
#main
location / {
if ($ssl_protocol = "") {
rewrite ^(/)$ https://$host$1;
}
proxy_pass http://mycard.github.io/;
}
#mycard-server
location /rooms.json {
proxy_pass http://localhost:9998/rooms.json;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
#match
location /match {
proxy_pass http://phoenix6.my-card.in:9997/match.json;
}
#humanstxt
location /humans.txt {
proxy_set_header Accept-Encoding '';
proxy_pass http://mycard.github.io/humans.txt;
}
location /humans {
proxy_pass http://zh99998.github.io/humans.html/;
}
location /eula {
rewrite (.*) https://github.com/mycard/mycard/wiki/mycard:%E4%BD%BF%E7%94%A8%E6%9D%A1%E6%AC%BE redirect;
}
location /join {
rewrite (.*) https://github.com/mycard/mycard/wiki/%E5%8A%A0%E5%85%A5%E6%88%91%E4%BB%AC redirect;
}
#shinkirou
location /shinkirou/ {
proxy_pass http://mycard.github.io/shinkirou-web/;
}
}
#redirect
server {
server_name www.my-card.in card.touhou.cc;
rewrite ^/(.*)$ http://my-card.in/$1 permanent;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment