2016-09-19 1 views

답변

0

매우 쉽고 이미 구현했습니다. wittyfeed.com을 확인하실 수 있으며, 모바일 및 데스크톱 용으로 다른 파일을 제공합니다. 요청이 모바일에서 제공하거나 b.html 경우가 a.html로, 변수 $ 산업사에 대한 값을 설정으로 다음과 같이 수행 할 수 있습니다

,

http { 
    .... 
    map $http_user_agent $ind { 
     "~*mobile" a.html; 
     default b.html; 
    } 


    server { 
     ... 
     index $ind; 
     ... 
     location/{ 
      try_files $uri $uri/ $ind; 
     } 
    } 
} 

위의 코드는 실행됩니다. 그런 다음 그에 따라 파일을 가져 오려고 시도합니다. :)

편집 된 w.r.t. 응답을, 아래, * 테스트하지

http { 
    ... 
    map $http_user_agent $proxy_addr { 
     "~*mobile" test-qa.firebaseapp.com/mobile; 
     default localhost:8080/test/jsp/index.jsp; 
    } 

    server { 
     ... 
     location /test { 
     proxy_pass $proxy_addr; 
     } 
    } 
} 
+0

고맙습니다 주석, 내 두 개의 파일을 다른 서버에있는 그래서 예 same.if을 달성 할 수 다음 –

+0

네 가능, 당신은 proxy_pass을 활용할 수있는 방법, 좋아요, 위치/{proxy_pass server_address/$ ind; } – Satys

+0

현재 내가이 HTTP 같이가 { } 서버 { 가 \t \t 80을 듣고; server_name dev.example.com; \t \t 루트/usr/local/tomcat7/webapps/ROOT; 위치/테스트 { \t \t \t proxy_pass http://127.0.0.1:8080; \t \t \t proxy_read_timeout 900; \t \t} 은} 내가 포트 8080에 runnung 자바에서 응용 프로그램을하고 난 사용자가 바탕 화면에서 때 다음 페이지는 자바 가진 포트 8080 (로컬 호스트에서 역할을 할 것을 원하는 : 8080/테스트/JSP /index.jsp) 사용자가 모바일에서 온 경우 페이지가이 URL에서 제공됩니다 https://test-qa.firebaseapp.com/mobile/ –

관련 문제