我有一个Nginx代理传递,重定向到我的Widlfly部署的HTTPS地址。
如果我只通过http://调用我的URL,页面会正常加载。但如果我通过https://调用URL,我会在浏览器开发工具中收到以下消息:
由于https://www.planyourplaylist.com/VAADIN/build/vaadin-bundle-b84b24669ab9c1964b96.cache.js存在未经批准的MIME类型(“text/html”),加载“www.example.com“的模块被阻止。
Uncaught (in promise) TypeError: ServiceWorker script at https://www.planyourplaylist.com/sw.js for scope https://www.planyourplaylist.com/ encountered an error during installation.
我的nginx的widlfly.conf看起来像这样:
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;
}
}
谢谢你的帮助。:)
1条答案
按热度按时间izj3ouym1#
感谢@SimonMartinelli提供的帖子链接。
这个问题实际上是通过在nginx中包含mime.types文件来解决的。不幸的是,我不明白的是,我已经在nginx.conf文件中包含了mime.types文件,正如ofiziellen示例中所描述的那样。
https://www.nginx.com/resources/wiki/start/topics/examples/full/
因此,如果我将mime.types文件包含在http{...}下的nginx.conf文件中,或者包含在server{...}下的widlfly.conf文件中,会有什么区别呢?
据我所知,在加载nginx.conf文件时,应该已经包含了该文件。
谢谢你的帮助。:)