Home > front end >  Nginx proxy-pass to HTTPS Wildfly gives blocked MIME Type message and dont load UI
Nginx proxy-pass to HTTPS Wildfly gives blocked MIME Type message and dont load UI

Time:11-13

I have a Nginx proxy pass that redirects to the HTTPS address of my Widlfly deployant.

If I call my URL only via http:// the page loads normally. But if I call the url with https:// I get these messages in the browser developer tool:

Loading the module of "https://www.planyourplaylist.com/VAADIN/build/vaadin-bundle-b84b24669ab9c1964b96.cache.js" was blocked due to an unapproved MIME type ("text/html").

Uncaught (in promise) TypeError: ServiceWorker script at https://www.planyourplaylist.com/sw.js for scope https://www.planyourplaylist.com/ encountered an error during installation.

My widlfly.conf for the nginx looks like this:

upstream wildfly {
    # List of Widlfly Application Servers
    server <ip-adress>;
}


server {
    listen 80;
    server_name <ip-adress>;

  location / {
    #return 301 https://<ip-adress>:8443/;
    proxy_pass http://<ip-adress>:8080/;
  }

  location /management {
    proxy_pass http://<ip-adress>:9990/management;
  }

  location /console {
    proxy_pass http://<ip-adress>:9990/console;
  }

  location /logout {
    proxy_pass http://<ip-adress>:9990/logout;
  }

  location /error {
    proxy_pass http://<ip-adress>:9990;
  }
}

server {
  listen 443 ssl ;
  server_name <ip-adress>;
  ssl_certificate ssl_cert/planyourplaylist_cert.cer;
  ssl_certificate_key ssl_cert/planyourplaylist_private.key;
  ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers         HIGH:!aNULL:!MD5;


  # when user requests /
  location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass https://<ip-adress>:8443/;
  }

  location ~ \.(css|js|png|gif|jpeg|jpg|swf|ico|woff){
        root /opt/wildfly/standalone/deployments/planyourplaylist.war;
        expires 360d;
    }
}

Thanks for your help. :)

CodePudding user response:

Thanks to @SimonMartinelli for the link to the post.

The problem was actually fixed by including the mime.types file in nginx. What I unfortunately dont understand is, I had the mime.types file already included but in the nginx.conf file as described in the ofiziellen eyample.

https://www.nginx.com/resources/wiki/start/topics/examples/full/

Therefore the question where is the difference if I include the mime.types file in the nginx.conf file under http{...} or in the widlfly.conf under server{...}.

In my understanding the file should already be included when the nginx.conf file is loaded.

Thanks for your Help. :)

  • Related