Hi Francis,
thanks for the details. I guess the trick is first to bypass a QNAP internal redirect to the NAS GUI (if possible or to integrate it on the first request). And second to to adapt the login request the right way. (btw: I try to avoid to change the qnap service, because of the regular QNAP firmware updates.)
For the first topic the internal network traffic analysis from Firefox shows a lot of GET requests and some POST regarding the login:
On the address bar a request of http://qnap/ will be redirected to http://qnap:8080/ >> http://qnap:8080/redirect.html?count=0.xxxx >> http://qnap:8080/cgi-bin/QTS.cgi?count=yyyyyy and finally to http://qnap:8080/cgi-bin/ which "delivers" the login page.
So, the service to enter the qnap is available at http://qnap:8080/cgi-bin/ (There are also other services available like the photo station (e.g. http://qnap:8080/photo or the music station, if activated).
I don't know why QNAP uses a redirect (I guess it has something to do with the QNAP webserver), so I concentrate on the second point: "Bypassing the redirect by request the login page directly" (which could be a good workaround).
So I tried it with http://qnap:8080/cgi-bin/login.html locally, which leads successfully to the login page http://qnap:8080/cgi-bin/. Changing the location part as suggested into:
location ^~ /nas/ {
proxy_pass http://qnap:8080/cgi-bin/;
proxy_set_header X-Real-IP $remote_addr;
}
and trying the address https://example.com/nas/login.html results in a broken login page with a lot of 404 errors.
Comparing the http headers of both login pages the one from the internal request contains a bit more. There is a additional Connection "Keep-Alive" and a Keep-Alive with "timeout=15, max=97" and another server name which is "http server 1.0" (that should be the QNAP internal server description) instead of "nginx/1.6.2" via the external request.
The content type of the GET requests doesn't change using the external address, it stays on html. Internal requests show different content types like css, js, xml, jpg.
Can anybody tell why it stays on external requests on content type "html"? Does it have to do something with Cache-Control?
I would appreciate any hint.
Kind regs
no.1