Reputation: 2070
I have this code:
server {
listen 80;
server_name example.com;
return 301 https://www.sajufortune.com$request_uri;
}
server {
listen 80;
server_name www.example.com;
if ($http_x_forwarded_proto != 'https') {
rewrite ^ https://$host$request_uri? permanent;
}
set $alb internal-saju-alb-before-w43.us-west-2.elb.amazonaws.com;
location / {
proxy_pass $alb;
}
}
server {
listen 80;
location /ping/ {
return 200 'pong';
}
}
I got this returning 200 code from here:
I want to 200 response pong
to /ping/
request from any url except example.com
, www.example.com
.
How can I do this?
Upvotes: 0
Views: 2289
Reputation: 539
Try the below config
server {
listen 80;
server_name example.com;
return 301 https://www.sajufortune.com$request_uri;
}
server {
listen 80;
server_name www.example.com;
if ($http_x_forwarded_proto != 'https') {
rewrite ^ https://$host$request_uri? permanent;
}
set $alb internal-saju-alb-before-w43.us-west-2.elb.amazonaws.com;
location / {
proxy_pass $alb;
}
}
server {
listen 80;
server_name _;
location /ping/ {
return 200 'pong';
}
}
Upvotes: 1
Reputation: 1181
According to http://nginx.org/en/docs/http/ngx_http_core_module.html#listen you need to either put the ping/pong server-block on the top, or append default_server
on the listen
option (e.g. listen 80 default_server;
)
Upvotes: 1