<p>I deployed an application running on nginx in Kubernetes, it's a simple static <code>index.html</code>. I defined a button with a url to <code>http://backservice:8080/action</code>. <code>backservice</code> is a k8s service backing a Spring application. </p>

<p>The problem is, when I click on that button, nothing happens. <code>backservice</code> is not hit. I expect a <code>CORS</code> error but it seems like nginx blocks all outbound requests. I don't want to proxy the backend service into nginx. </p>

<p>Nginx config:</p>

<pre><code>user  nginx;
worker_processes  auto;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}
</code></pre>

<p>Server conf:</p>

<pre><code>server {
    listen       80;
    server_name  _;
    root /usr/share/nginx/html; 

    location / {
        index  index.html index.htm;
        try_files $uri $uri/ /index.html;
    }

    location /svg/ {
    }

    location /assets/ {
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    }
}
</code></pre>

<p>The <code>backendservice</code> is in the same namespace as the nginx app.</p>

<p>Your static app runs in your browser. The browser isn't part of the k8s cluster so it is not aware of the URL <code>http://backservice:8080/action</code></p>

<p>Expose your backend service using Ingress. For example <code>https://backend.example.com/action</code></p>

<p><a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/ingress/</a> 
(You can expose using Loadbalancer type too but I suggest Ingress)</p>

<p>Then change your frontend code to hit <code>https://backend.example.com/action</code></p>
