[GH-ISSUE #143] Nginx works with frontail on http but not on https #101

Closed
opened 2026-03-03 16:04:25 +03:00 by kerem · 5 comments
Owner

Originally created by @hamwong on GitHub (Oct 17, 2018).
Original GitHub issue: https://github.com/mthenw/frontail/issues/143

Nginx works with frontail on http but not on https, as browser will report "too many redirect eroor" when Nginx connect to frontail https, frontail https without ngix also fine, can this be fixed?

Originally created by @hamwong on GitHub (Oct 17, 2018). Original GitHub issue: https://github.com/mthenw/frontail/issues/143 Nginx works with frontail on http but not on https, as browser will report "too many redirect eroor" when Nginx connect to frontail https, frontail https without ngix also fine, can this be fixed?
kerem closed this issue 2026-03-03 16:04:26 +03:00
Author
Owner

@mthenw commented on GitHub (Oct 17, 2018):

Can you paste your nginx configuration?

<!-- gh-comment-id:430533312 --> @mthenw commented on GitHub (Oct 17, 2018): Can you paste your nginx configuration?
Author
Owner

@hamwong commented on GitHub (Oct 20, 2018):

below code only changed server name and SSL location, SSL is register by letsencrypt

`worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

sendfile        on;
keepalive_timeout  65;

server {
    listen       80;
    listen [::]:80;
    server_name  www.XXYYZZ.com;


    return 301                      https://$server_name$request_uri;


    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

}

server {
listen 443 ssl;
server_name www.XXYYZZ.com;

ssl_certificate                 /etc/ssl/openhab.crt; 
ssl_certificate_key             /etc/ssl/openhab.key; 
add_header                      Strict-Transport-Security "max-age=31536000"; # Remove if using self-signed and are having trouble.

location / {
    proxy_pass                            http://192.168.1.2:8080;
    proxy_set_header Host                 $http_host;
    proxy_set_header X-Real-IP            $remote_addr;
    proxy_set_header X-Forwarded-For      $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto    $scheme;
    satisfy                               any;
    allow                                 192.168.1.1/24;
    allow                                 127.0.0.1;
    deny                                  all;
    auth_basic                            "Username and Password Required";
    auth_basic_user_file                  /etc/nginx/.htpasswd;
}

location /grafana/ {
    proxy_pass http://192.168.1.2:3000/;
}
location /frontail/ {
    proxy_pass https://192.168.1.2:9001/frontail;
}

}`

<!-- gh-comment-id:431585680 --> @hamwong commented on GitHub (Oct 20, 2018): below code only changed server name and SSL location, SSL is register by letsencrypt `worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; listen [::]:80; server_name www.XXYYZZ.com; return 301 https://$server_name$request_uri; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 443 ssl; server_name www.XXYYZZ.com; ssl_certificate /etc/ssl/openhab.crt; ssl_certificate_key /etc/ssl/openhab.key; add_header Strict-Transport-Security "max-age=31536000"; # Remove if using self-signed and are having trouble. location / { proxy_pass http://192.168.1.2:8080; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; satisfy any; allow 192.168.1.1/24; allow 127.0.0.1; deny all; auth_basic "Username and Password Required"; auth_basic_user_file /etc/nginx/.htpasswd; } location /grafana/ { proxy_pass http://192.168.1.2:3000/; } location /frontail/ { proxy_pass https://192.168.1.2:9001/frontail; } }`
Author
Owner

@pacive commented on GitHub (Oct 21, 2018):

I had the same problem, the solution was to use
location /frontail {
instead of
location /frontail/ {

I however, have a different issue using https. I get an error in chrome:

Refused to execute script from 'https://<address>/frontail/socket.io/socket.io.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

What's strange is that the Content-type-header is set to application/javascript when loading over http, but text/html when loading over https. I believe this error is because of nginx though..

Edit:
This was also because of a / too much: using

proxy_pass    http://<address>/frontail;

instad of

proxy_pass    http://<address>/frontail/;

solved it!

<!-- gh-comment-id:431670506 --> @pacive commented on GitHub (Oct 21, 2018): I had the same problem, the solution was to use `location /frontail {` instead of `location /frontail/ {` I however, have a different issue using https. I get an error in chrome: ``` Refused to execute script from 'https://<address>/frontail/socket.io/socket.io.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. ``` What's strange is that the `Content-type`-header is set to `application/javascript` when loading over http, but `text/html` when loading over https. I believe this error is because of nginx though.. Edit: This was also because of a `/` too much: using ``` proxy_pass http://<address>/frontail; ``` instad of ``` proxy_pass http://<address>/frontail/; ``` solved it!
Author
Owner

@hamwong commented on GitHub (Oct 21, 2018):

I had the same problem, the solution was to use
location /frontail {
instead of
location /frontail/ {

I however, have a different issue using https. I get an error in chrome:

Refused to execute script from 'https://<address>/frontail/socket.io/socket.io.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

What's strange is that the Content-type-header is set to application/javascript when loading over http, but text/html when loading over https. I believe this error is because of nginx though..

Edit:
This was also because of a / too much: using

proxy_pass    http://<address>/frontail;

instad of

proxy_pass    http://<address>/frontail/;

solved it!

Thank you @pacive, it works!! unblievable.

<!-- gh-comment-id:431684317 --> @hamwong commented on GitHub (Oct 21, 2018): > > > I had the same problem, the solution was to use > `location /frontail {` > instead of > `location /frontail/ {` > > I however, have a different issue using https. I get an error in chrome: > > ``` > Refused to execute script from 'https://<address>/frontail/socket.io/socket.io.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. > ``` > > What's strange is that the `Content-type`-header is set to `application/javascript` when loading over http, but `text/html` when loading over https. I believe this error is because of nginx though.. > > Edit: > This was also because of a `/` too much: using > > ``` > proxy_pass http://<address>/frontail; > ``` > > instad of > > ``` > proxy_pass http://<address>/frontail/; > ``` > > solved it! Thank you @pacive, it works!! unblievable.
Author
Owner

@mthenw commented on GitHub (Oct 21, 2018):

Thanks @pacive for the help.

<!-- gh-comment-id:431705684 --> @mthenw commented on GitHub (Oct 21, 2018): Thanks @pacive for the help.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/frontail#101
No description provided.