2023-03-13 14:23:59 +08:00
|
|
|
**vim laptop-ingress.yaml**
|
|
|
|
|
|
|
|
```
|
|
|
|
apiVersion: networking.k8s.io/v1
|
|
|
|
kind: Ingress
|
|
|
|
metadata:
|
|
|
|
annotations:
|
|
|
|
nginx.ingress.kubernetes.io/server-snippet: |
|
|
|
|
set $agentflag 0;
|
|
|
|
if ($http_user_agent ~* "(Android|iPhone|Windows Phone|UC|Kindle)" ){
|
|
|
|
set $agentflag 1;
|
|
|
|
}
|
|
|
|
if ( $agentflag = 1 ) {
|
|
|
|
return 301 http://m.test.com;
|
|
|
|
}
|
|
|
|
name: laptop
|
|
|
|
namespace: study-ingress
|
|
|
|
spec:
|
2023-12-10 06:23:04 +08:00
|
|
|
ingressClassName: nginx
|
2023-03-13 14:23:59 +08:00
|
|
|
rules:
|
|
|
|
- host: test.com
|
|
|
|
http:
|
|
|
|
paths:
|
|
|
|
- backend:
|
|
|
|
service:
|
|
|
|
name: laptop
|
|
|
|
port:
|
|
|
|
number: 80
|
|
|
|
path: /
|
|
|
|
pathType: ImplementationSpecific
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|