<p>I have my assets on s3 and my service is deployed on kubernetes. Is it possible to define proxy pass in nginx-ingress. My current nginx proxy_pass assets to s3 and I want to replicate in kubernetes.</p>

<pre><code>location /assets/ {
          proxy_pass https://s3.ap-south-1.amazonaws.com;
   }
</code></pre>

<p>I tried this but its not working</p>

<pre><code>nginx.ingress.kubernetes.io/server-snippet: |
      location /assets/ {
              proxy_pass https://s3.ap-south-1.amazonaws.com/assets/;
      }
</code></pre>

<p>You can use <code>proxy_pass</code> in Ingress as in normal Nginx.</p>

<p>So if you have some local or public HTTP/HTTPS service which is outside of Kubernetes cluster and you want to serve this through Ingress, you just need this:</p>

<pre><code>kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: owncloud
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    ingress.kubernetes.io/ssl-redirect: "true"
    ingress.kubernetes.io/secure-backends: "true"
    ingress.kubernetes.io/force-ssl-redirect: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/server-snippet: |
      location ~ "^/(.*)" {
        proxy_pass http://192.168.250.100:8260;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto https;
      }
spec:
  rules:
  - host: owncloud.example.com
  tls:
  - hosts:
    - owncloud.example.com
    secretName: owncloud-example-tls
</code></pre>

<ul>
<li><p>Remove <code>ssl</code>, <code>secure</code>, <code>X-Forwarded-Proto</code> and <code>tls</code> bits if you don't need HTTPS</p></li>
<li><p>You can add more location blocks such as <code>~ "^/api/(.*)"</code> so it works as normal Nginx</p></li>
<li><p>It will retain domain name so for instance in browser's address bar you will have original one. In case you need to do a full redirect, start experimenting with <code>proxy_set_header Host $host;</code> removal</p></li>
</ul>

<p>Hope that helps someone</p>
