<p>Can ingress rewrite 405 to the origin url and change the http-errors <code>405</code> to <code>200</code>?</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: frontend-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
  - http:
    paths:
    - path: /page/user/(.*)
      pathType: Prefix
      backend:
        serviceName: front-user
        servicePort: 80
    - path: /page/manager/(.*)
      pathType: Prefix
      backend:
        serviceName: front-admin
        servicePort: 80
</code></pre>
<p>Ngnix can realize that visit a html page by a <code>post</code> method but I want to know how to realize by ingress.</p>
<pre><code>server {
    listen 80;
    # ...
    error_page 405 =200 @405;
    location @405 {
        root /srv/http;
        proxy_method GET;
        proxy_pass http://static_backend;
    }
}
</code></pre>
<p>This is an e.g. that ngnix realize that visit a html page by a <code>post</code> method to change <code>405</code> to <code>200</code> and change the method to <code>get</code></p>

<p>You can use <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#server-snippet" rel="nofollow noreferrer">server snippet</a> annotation to achieve it.</p>
<p>Also I rewrote your ingress from <code>extensions/v1beta1</code> apiVersion to <code>networking.k8s.io/v1</code>, because starting kubernetes <code>v1.22</code> previous <code>apiVersion</code> is be removed:</p>
<pre><code>$ kubectl apply -f ingress-snippit.yaml 
Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
</code></pre>
<p><code>Ingress-snippet-v1.yaml</code></p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: frontend-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/server-snippet: | # adds this block to server
      error_page 405 =200 @405;
      location @405 {
        root /srv/http;
        proxy_method GET;
        proxy_pass http://static_backend; # tested with IP since I don't have this upstream
      }
spec:
  rules:
  - http:
      paths:
      - path: /page/user/(.*)
        pathType: Prefix
        backend:
          service:
            name: front-user
            port:
              number: 80
      - path: /page/manager/(.*)
        pathType: Prefix
        backend:
          service:
            name: front-admin
            port:
              number: 80
</code></pre>
<hr />
<p>Applying manifest above and verifying <code>/etc/nginx/nginx.conf</code> in <code>ingress-nginx-controller</code> pod:</p>
<pre><code>$ kubectl exec -it ingress-nginx-controller-xxxxxxxxx-yyyy -n ingress-nginx -- cat /etc/nginx/nginx.conf | less
...
## start server _
        server {
                server_name _ ;
                
                listen 80 default_server reuseport backlog=4096 ;
                listen 443 default_server reuseport backlog=4096 ssl http2 ;
                
                set $proxy_upstream_name &quot;-&quot;;
                
                ssl_certificate_by_lua_block {
                        certificate.call()
                }
                
                # Custom code snippet configured for host _
                error_page 405 =200 @405;
                location @405 {
                        root /srv/http;
                        proxy_method GET;
                        proxy_pass http://127.0.0.1; # IP for testing purposes
                }
                
                location ~* &quot;^/page/manager/(.*)&quot; {
                        
                        set $namespace      &quot;default&quot;;
                        set $ingress_name   &quot;frontend-ingress&quot;;
                        set $service_name   &quot;front-admin&quot;;
                        set $service_port   &quot;80&quot;;
                        set $location_path  &quot;/page/manager/(.*)&quot;;
                        set $global_rate_limit_exceeding n;
...
</code></pre>
