Apache vs lighthttpd: MIME 유형에 따라 다른 동작

Apache vs lighthttpd: MIME 유형에 따라 다른 동작

저는 Apple 장치용 Python으로 자동 VPN 프로비저닝 웹 포털인 애플리케이션을 작성했습니다.

나에게 버그가 있는 것은 테스트 서버와 프로덕션 서버 간의 동작 차이입니다. 전자는 를 사용 Apache하고 후자는 를 사용하고 있습니다 lighthttpd.

lighhttpd파일 이 .mobileconfig열리고 "실행"됩니다. 예를 들어 SysPrefs가 자동으로 열리는 반면 Apache에서는 그런 일이 발생하지 않습니다.

lighhtpd나는 이미 적절한 정의에 관해 훨씬 더 느슨하다는 것을 알았습니다 . 그러나 당면한 문제는 Safari가 파일을 올바르게 Content-Type로드하고 "자동 실행"하는 반면 ..mobileconfiglighthttpdApache

mime.type두 서버 모두에서 다음과 같이 해당 항목을 적절하게 정의했다는 사실이 더 짜증납니다 .

lighthttpd.conf

$HTTP["url"] =~ "\.mobileconfig$" {
    setenv.add-response-header = ( "Content-Disposition" => "attachment" )
    mimetype.assign = (".mobileconfig" => "application/x-apple-aspen-config",
                    "" => "application/octet-stream")
}

Apache에서와 마찬가지로 다음과 같습니다.

dovpn.conf(가상호스트)

AddType application/x-apple-aspen-config .mobileconfig

add-response-header차이점 에 대한 첫 번째 단서는 실제로 lighthttpd.

생성된 HTML에는 다음이 있습니다.

a download="profile.mobileconfig" href="../upload/8bd16b26-1473-4994-9803-8268a372cd0d.mobileconfig" type="application/octet-stream">Download automatic profile/a

그리고 Javascript를 통해 자동으로 다운로드합니다.

//If in Safari - download via virtual link click
if (window.downloadFile.isSafari) {
    //Creating new link node.
    var link = document.createElement('a');
    link.href = sUrl;
    if (link.download !== undefined) {
        //Set HTML5 download attribute. This will prevent file from opening if supported.
        var fileName = sUrl.substring(sUrl.lastIndexOf('/') + 1, sUrl.length);
        link.download = fileName;
    }
    //Dispatching click event.
    if (document.createEvent) {
        var e = document.createEvent('MouseEvents');
        e.initEvent('click', true, true);
        link.dispatchEvent(e);
        return true;
    }
}

생성 페이지의 콘텐츠에는 Content-Type만 있습니다.

Content-Type: text/html\n\n

Apache와 lighthttpd 모두에서. 나는 전선을 통해 냄새를 맡았으며 lighthttpd.

setenv.add-response-headerApache와 유사한 기능을 복제할 수 있습니까 ?

이미 Apache 호스트에 추가하려고 시도했습니다.

<Files "*.mobileconfig">
      Header set Content-Disposition attachment
</Files>

그리고

SetEnvIf Request_URI "\.mobileconfig$" change_header
Header set Content-Disposition attachment env=change_header

그리고

SetEnvIf Request_URI "\.mobileconfig$" change_header
Header always add "Content-Disposition" "attachment" env=change_header

그리고

<Files "*.mobileconfig">
    Header append Content-Disposition attachment
</Files>

또한 실제 디렉토리에서 다음을 사용하여 .htaccess파일을 생성해 보았습니다.

<IfModule mod_headers.c>
    <FilesMatch "\.mobileconfig$">
        ForceType application/octet-stream
        Header append Content-Disposition "attachment"
        Allow from all
    </FilesMatch>
</IfModule>

그리고

<IfModule mod_headers.c>
    <FilesMatch "\.mobileconfig$">
        ForceType application/octet-stream
        Header add Content-Disposition "attachment"
        Allow from all
    </FilesMatch>
</IfModule>

두 경우 모두 , attachment게다가 "attachment".

mod_headers는 Apache/Debian 9에서 기본적으로 활성화되어 있으며 이러한 대안 중 어느 것도 작동하지 않습니다.

사실 방금 기억나는 것은 lighthttpdHTTP와 ApacheHTTPS를 사용하고 있다는 것입니다. 나는 HTTPS를 사용하여 lighthttpd를 테스트했으며 HTTPS를 통해서도 작동하지만 Apache는 작동하지 않습니다.

curl -k -I https://localhost/cgi-bin/vpn.pylighthttpd 서버의 출력 :

HTTP/1.1 200 OK
Content type: text/html
Content-Length: 331
Date: Thu, 01 Jun 2017 09:03:26 GMT
Server: lighttpd/1.4.45

curl -k -I https://localhost/cgi-bin/vpn.pyApache 서버의 출력 :

HTTP/1.1 200 OK
Date: Thu, 01 Jun 2017 09:05:25 GMT
Server: Apache
Vary: Accept-Encoding
X-Frame-Options: sameorigin
Content-Type: text/html; charset=UTF-8

게다가 Apache에서도:

$curl -k -I https://localhost/download/xxx.mobileconfig
HTTP/1.1 200 OK
Date: Thu, 01 Jun 2017 09:13:35 GMT
Server: Apache
Last-Modified: Thu, 01 Jun 2017 03:08:57 GMT
ETag: "1f3b-550dd5b89d8df"
Accept-Ranges: bytes
Content-Length: 7995
X-Frame-Options: sameorigin
Content-Disposition: attachment
Content-Type: application/x-apple-aspen-config

Safari 사용->개발->웹 검사기 표시->디버거->기본 페이지 클릭->curl로 복사하면 "curl'만 반환됩니다.https://xxxx/cgi-bin/vpn.py붙여넣을 때 ' -Xnull"입니다.

또한 비활성화를 시도했지만 X-Frame-Options: "sameorigin"아무런 차이가 없었습니다. (나는 그것이 긴 가능성이라는 것을 알았습니다)

답변1

.htaccess파일을 사용하면 헤더에 Content-Disposition을 추가하는 문제가 해결된 것 같습니다 .

그러나 기능을 복제하는 데 따른 문제와 디버깅 및 테스트의 복잡성이 추가되는 것은 다른 설명이 있는 것 같습니다.

.mobileconfig최신 베타 버전과 최신 버전의 Sierra 업데이트 파일은 모두 보안상의 이유로 Safari의 "안전한" 파일 열기 목록에서 제외된 것 같습니다 .

어제(또는 그저께) 직장에서, 오늘 집에서 MacOS를 업데이트했는데 더 이상 .mobileconfig프로덕션 또는 사전 프로덕션 시스템에서 파일을 자동으로 열 수 없습니다.

.mobileconfig방금 iPhone을 iOS 10.3.3 베타로 업데이트했는데, 이는 Apple이 프로비저닝 파일을 잠재적으로 위험한 것으로 취급하는 경향을 확인하는 것 같습니다 . 이제 해당 파일을 클릭하면 새로운 경고가 표시됩니다.

이 웹사이트는 구성 프로필을 표시하기 위해 설정을 열려고 합니다. 이것을 허용하시겠습니까?
무시 - 허용

관련 정보