2017-04-02 1 views
0

iOS 앱에서 범용 링크를 구현하려고하므로 웹 서버의 루트에 "apple-app-site-association"파일이 있어야합니다. .Nginx가 서비스를 제공하는 대신 파일을 다운로드합니다 (PHP가 아님)

나는 nginx를 사용하고 있으며 모든 것이 (아마도 가정으로) 올바르게 설정되어 있습니다. 내 웹 사이트 작동, PHP 작품, 내 API 작동합니다. 유일한 문제는 내가 "test.com/apple-app-site-association"사이트로 이동했을 때 브라우저 (iOS 브라우저는 물론)가 파일을 표시하는 대신 다운로드하기 때문에 내 범용 링크가 작동하지 않는다는 것입니다 .

누군가가 nginx에서 사이트를 다운로드하여 대신 제공하는 것을 막는 방법에 대한 아이디어가 있다면 기꺼이 생각합니다. 하는 REST API 클라이언트를 사용하여

server { 
    listen 80 default_server; 
    listen [::]:80 default_server; 

    server_name test.com www.test.com; 
    return 301 https://$server_name$request_uri; 
} 

server { 
    # SSL configuration 
    listen 443 ssl http2 default_server; 
    listen [::]:443 ssl http2 default_server; 

    include snippets/ssl-test.com.conf; 
    include snippets/ssl-params.conf; 

    client_max_body_size 1m; 

    root /var/www/test.com/web; 
    index index.html index.htm index.php; 

    access_log   /var/log/nginx/test.com.access.log; 
    error_log    /var/log/nginx/test.com.error.log; 

    #Default url rewrites 
    location/{ 

    #root /var/www/test.com/web; 
    try_files $uri $uri/ /index.html; 
    autoindex off; 
    index index.html index.htm index.php; 

    } 

    location ~ \.php$ { 
    # try_files $uri =404; 
    set $path_info $fastcgi_path_info; 
    root /var/www/test.com/web; 
    fastcgi_index index.php; 
    fastcgi_split_path_info ^(.+\.php)(/.*)$; 
    try_files $uri $uri/ /index.php$is_args$args; 
    include /etc/nginx/fastcgi_params; 
    fastcgi_pass 127.0.0.1:9000; 

    fastcgi_param SCRIPT_FILENAME $request_filename; 
    fastcgi_param APP_ENV dev; 

    } 

    #Apple universal links 
    location = /apple-app-site-association { 
    default_type application/pkcs7-mime; 
    } 

    #Redirect all requests under /user/ to the "get App" page 
    location /user/ { 
    return 301 https://test.com/get_app.html; 
    # try_files $uri $uri/ /get_app.html; 
    } 

    #Let's Encrypt SSL Validation 
    include snippets/letsencrypt.conf; 
} 

파일을 요청하는 것이 올바른 것으로 나타납니다 다음 헤더 (NO "첨부 파일"헤더)를 제공합니다 : 내 사이트가 밖으로 편집하여 아래

내 서버의 구성입니다 :

Server: nginx/1.10.3 
Date: Sun, 02 Apr 2017 17:25:42 GMT 
Content-Type: application/pkcs7-mime 
Content-Length: 149 
Last-Modified: Sun, 02 Apr 2017 16:07:02 GMT 
Connection: keep-alive 
Etag: "58e121a6-95" 
Strict-Transport-Security: max-age=63072000; includeSubdomains 
X-Frame-Options: DENY 
X-Content-Type-Options: nosniff 
Accept-Ranges: bytes 
+1

시도해 봤어'Content-Disposition : inline' – Deadooshka

+0

정말 고마워! 'add_header Content-Disposition inline;과'default_type application/json; '을 모두 추가 한 후에 파일이 올바르게 제공됩니다! –

답변

0

브라우저뿐만 아니라 Content-Type: application/pkcs7-mime을 지원하지 않을 수 있습니다 IOS는 브라우저. 내용이 사람이 읽을 수있는 경우 Content-Type: text/plain으로 설정하십시오.

this link도 도움이되는지 확인하십시오.

관련 문제