Skip to content

nginx

server{
server_name old-domain.com;
rewrite ^(.*)$ http://new-domain.com$1 permanent;
}
server{
server_name old-domain.com;
rewrite ^(.*)$ http://new-domain.com$ redirect;
}

メソッドなどで処理をかえる方法

Section titled “メソッドなどで処理をかえる方法”
# Ex. POST以外を拒否
if ($request_method !~ ^(POST)$ ) {
return 405;
}
# Ex. GET/POSTを許容
if ($request_method !~ ^(GET|POST)$ ) {
return 405;
}
# Ex. DELETEのみ拒否
if ($request_method ~ ^(DELETE)$ ) {
return 405;
}
location / {
if ($remote_addr = xxx.xxx.xxx.xxx) {
ploxy_pass http://hogehoge1
}
if ($remote_addr = yyy.yyy.yyy.yyy) {
ploxy_pass http://hogehoge2
}
}
location / {
if ($remote_addr ~* xxx\.xxx\.xxx\.*) {
ploxy_pass http://hogehoge1
}
if ($remote_addr ~* yyy\.yyy\.yyy\.*) {
ploxy_pass http://hogehoge2
}
}