I have php5.6 application running on kubernetes and exposed using ingress. Php application contains nginx and php5.6 fpm. When i expose service using kubectl port-forward <service> 9090:80 "localhost:9090/admin" redirect to "localhost:9090/admin/index/login" page as expected. This redirection rule is not defined in nginx file. It happens internally by php application. But when i expose service using ingress, and hit "www.demo.example.com/admin" it redirects to "www.demo.example.com/admin/index/login" but gives error redirected you too many times. Below is ingress file that i'm using. I'm trying to figure out why this is happening but no luck. No error is in error.log but in access.log "GET /admin/index/login HTTP/1.1" 301 31 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/<ip> Safari/537.36"
kind: Ingress
metadata:
name: php-web-ingress
labels:
name: php-web-ingress
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: "www.demo.example.com"
http:
paths:
- path: /
backend:
serviceName: www-service
servicePort: 80
- path: /wp-admin
backend:
serviceName: wordpress
servicePort: 80
- path: /admin/
backend:
serviceName: php-web-service
servicePort: 80
-----------------------------------------------
Nginx.conf
server {
listen 80;
server_name www.demo.example.com;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /sites/www/public/;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
}