iPad에서 만든 HTTP 요청을 어떻게 리디렉션합니까?
iPad에서는 jailbreaking없이 hosts 파일을 편집 할 수 없으므로 어떻게 웹 트래픽을 다른 URL로 임의로 리디렉션 할 수 있습니까?
이는 개발 시스템으로 리디렉션하려는 가상 호스트 구성을 사용하는 웹 사이트를 개발하는 등의 작업에 중요합니다.
(이 질문과 관련이 있습니다 : iPad의 호스트 파일을 편집 할 수 있습니까? )
iPad의 이러한 제한을 극복하는 방법 은 hosts 파일을 편집 할 수있는 다른 컴퓨터에서 실행 되는 Squid 와 같은 HTTP 프록시 서버를 사용하는 것입니다.
iPad의 설정-> 네트워크-> Wi-Fi-> (네트워크)에서 수동으로 설정할 수있는 HTTP 프록시 설정이 있습니다. 여기에 프록시 정보를 입력하십시오.
이것이 설정되면 hosts 파일을 변경하는 것처럼 iPad를 조작 할 수 있습니다.
개발 기계의 IP 주소를 HTTP 프록시로 사용하기 위해 iPad 의 Wifi 설정을 수정해야한다는 것을 알았습니다 ( 앞서 기사 에서 설명 함 ).
그렇게하면 가상 호스트의 URL (예 :)을 입력하여 iPad에서 웹 응용 프로그램에 액세스 할 수 있습니다 local.mywebapp.com
. 쉽고 빠르지 만 Will Koehler의 솔루션과 달리 iPad에서 인터넷에 액세스 할 수 없습니다. 그러나 대부분의 경우 자체 응용 프로그램을 테스트하고 싶기 때문에 실제로 문제가되지는 않습니다.
Fiddler 또는 Charles와 같은 프록시 서버를 실행하는 컴퓨터에서 호스트 파일을 설정하고 해당 컴퓨터를 HTTP 프록시로 사용하도록 iPad를 구성하십시오.
Fiddler에서이를 수행하는 방법에 대한 지침은 다음과 같습니다. http://conceptdev.blogspot.com/2009/01/monitoring-iphone-web-traffic-with.html
그리고 이것은 Charles를위한 것입니다 : http://www.ravelrumba.com/blog/ipad-http-debugging/
개발자가 작업중인 Apache 서버가 이미있는 경우 이를 순방향 프록시로 쉽게 사용할 수 있습니다. 이것은 전체 절대 URL을 정말로 사용하는 WordPress 사이트에 특히 유용합니다.
아래 우분투 예제 :
첫 번째 단계는 /etc/hosts
개발자 서버에서 파일 을 편집하는 것 입니다. 사이트를 가리키는 서버의 로컬 IP를 추가하십시오.
127.0.0.1 dev.mysite.com
이 호스트 파일은 iPhone / iPad의 요청을 해결할 때 Apache 프록시에서 사용됩니다. 이제 아파치 부분을 설정해 보자 ...
먼저 일부 모듈을 설치해야 할 수도 있습니다.
sudo apt-get install libapache2-mod-proxy-html
sudo a2enmod proxy proxy_http proxy_html
sudo apache2ctl graceful
그런 다음 가상 호스트 파일을 만듭니다 (예 : /etc/apache2/sites-available/my-proxy
Listen *:8080
<VirtualHost *:8080>
ProxyRequests On
<Proxy *>
Order Deny,Allow
Deny from all
Allow from 192.168.1.0/24
</Proxy>
</VirtualHost>
vhost를 활성화하고 Apache를 다시 시작하십시오.
sudo a2ensite my-proxy
sudo apache2ctl graceful
그런 다음 설정> Wi-Fi> 네트워크 로 이동하여 "수동"프록시를 구성하십시오. Apache 서버의 IP와 포트를 입력하십시오. 그게 다야!
이 <Proxy *>
블록은 로컬 네트워크의 사용자 만이 프록시를 사용할 수 있도록합니다. 엄밀히 액세스를 제한하는 것은 필수적이다 당신이 앞으로 프록시를 사용하는 경우. ip2cidr의 페이지는이 시점에서 도움이 될 것입니다. (추가 조치로 : 8080 포트가 내 방화벽에 의해 차단되었습니다.)
iPad에서 개발중인 웹 앱을 테스트해야합니다. 개발자 컴퓨터에서 Apache를 사용하여 웹 앱을 실행하므로 가장 쉬운 해결책은 Apache mod_proxy를 사용하는 것입니다.
내 컴퓨터는 홈 네트워크에서 sapphire.local로 볼 수 있습니다.
테스트중인 웹 응용 프로그램은 demo.cms.dev의 dev 컴퓨터에서 호스팅됩니다 (POW를 사용하고 있습니다).
프록시를 설정하기 위해 httpd.conf에 다음 섹션을 추가했습니다.
<VirtualHost *:80>
ServerName sapphire.local
ProxyPass / http://demo.cms.dev/
ProxyPassReverse / http://demo.cms.dev/
ProxyPassReverseCookieDomain .cms.dev .sapphire.local
ProxyPreserveHost Off
</VirtualHost>
sapphire.local에서 들어오는 요청을 demo.cms.dev로 라우팅합니다. 이 방법은 한 번에 하나의 앱에서만 작동합니다. 다른 포트를 사용하여 추가 앱을 설정할 수 있다고 생각합니다. 누군가 더 나은 해결책이 있습니까?
웹 트래픽 리디렉션을 생성하기 위해 iOS 용 Weblock-AdBlock 앱 ( https://itunes.apple.com/us/app/weblock/id558818638?mt=8 )을 사용할 수도 있습니다.
This allows you to redirect any traffic matching certain rule to specified IP address. This will emulate adding an entry to /etc/hosts on your iOS device. If the hostname set in requests is handled by the IP you direct your traffic to, you can use this to test private API or even sniff traffic sent from other apps or websites. This unfortunately works only for http/https connections.
All this can be done only while on Wi-Fi (one of Weblock's limitations). There main advantage is that you can easily configure everything from your iOS device and there is no need to mess with DNS/proxy server configuration.
Here's an example:
- I've configured Weblock like this: http://i.stack.imgur.com/c5SUh.png
- Opened Safari and typed in www.google.com as URL
- This is the output in terminal on my Mac listening for connection on port 1234:
macbook-pro-tk:~ kpr$ nc -l -v -v 1234 GET http://www.google.com/ HTTP/1.1 Host: www.google.com Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Proxy-Connection: keep-alive PREF=ID=7722bc3c844a7c26:TM=1402073839:LM=1402073839:S=5bSJJsM2p0HgUP7L User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D201 Safari/9537.53 Accept-Language: en-us Accept-Encoding: gzip, deflate Connection: keep-alive
Weblock is also good to selectively redirect some URL's with regular expressions. You could redirect queries to certain endpoint only, while all other queries go to the IP returned from the DNS. This actually allows for even more fitting configuration that /etc/hosts does.
Example: If I create a URL redirect rule for htt*://somedomain.com/api/login* and some IP and port, I will see only traffic from this URL at this IP and port, while all other traffic to somedomain.com will go directly to the IP returned by the DNS. Notice it will work for both /api/login and /api/login?someparam=somevalue thanks to the wildcard * sign at the end of the rule.
I made it by using squidman on Mac. It's easy to set up and use.
I set it up in 5 minutes by following this article.
Update
Another thing is if you want to connect to the websites running on proxy server, in my case it's my Mac, you need to comment this line out in squidman->Preferences->Template
# protect web apps running on the proxy host from external users
# http_access deny to_localhost
You could setup an internal DNS server on your network (if one does not exist already) and setup an A record. Then ensure your DHCP is set to return said DNS server
You can also use http://xip.io/ using the instructions on that page you can enter the ip address and it will redirect you to the relevant local ip.
If you have a live website you can use for this:
You can add an A record to your DNS configuration: something.yourdomain.com which points to your local IP address, then add an entry for something.yourdomain.com to your virtual hosts file. Restart Apache, get your iOS device on the same network and you're good to go.
Here is a no configuration method for cross device/computer testing of a Mamp Pro Virtual host. The only limitation is you can only test one domain at a time, but for me this is fine when I'm developing. It is really simple however to change between virtual hosts directly in mamp.
Im running mamp pro 2, mountain lion. My sites folder contains the individual domain folders.
I found if you choose the specific ip of the local computer under the virtual host 'ip /port' and restart mamp this domain will become the default domain when viewing the localhost computers' ip address, or computer name, across the network.
For testing purposes this works great across all devices on the network, including the iPad. If you want to test another virtual host you can simply return the ip/port config to "*" and then reassign another domain to the computers ip address and restart.
The advantage of this simple approach is you can provide access to clients directly to your development sites when your on the same network without having to go through any configuration on their machine.
Hope this helps anyone else looking for simple solution.
Internal DNS Server is one of the option but that was too cumbersome to implement. We tried installing squid as proxy server but that also didnt work because it was redirecting the URL to new server and this redirection was seen on browser URL too.
Thing which finally worked for us was to install Fiddler on one of the server and use this server as the proxy server on ipad. Fiddler also has a feature to map sub-domains to IP address i.e. something similar to /etc/hosts.
Nice tutorial to do so: http://egalo.com/2012/05/29/testing-mac-web-site-using-local-hostname-on-mobile-device/
An other way is to connect the IPad via Local Hotspot with my MAC OS X and establish an port-forwarding to the development VM. To achieve this I'v done the following Steps:
- on MAC OS X create a WLAN-Hotspot Link how to do this
- connect the iPAD with the Hotspot-WLAN (on iPAD >> Settings >> WLAN)
- Add the ServerAlias to the local development-VM (details below)
- establish ssh-portforwarding
ssh -NL <IP-of-hotspot-host>:<source-port>:<url-to-local-vm>:80 <user-to-vm>
- int the iPADs Browser open the page with the IP
<IP-of-hotspot-host>:<source-port>
Where to get 'IP-of-hotspot-host':
After created hotspot there is a WLAN-Point in
MAC OS X system settings >> Network >> WLAN
Adding the ServerAlias:
At my development-VM (Apache2) in /etc/apache2/sites-available/dkr.dev.local I had to add the following:
<VirtualHost *:80> ... ServerAlias <IP-of-hotspot-host> ... </VirtualHost>
If you've been exploring this, and a few of the external links, you will possibly find this answer:
https://stackoverflow.com/a/24770097/3842985
It is about a light-weigh DNS server called dnsmasq. Super simple, very powerful, and can be used in conjunction with your internal or external DNS servers.
Much easier than installing squid, fiddling with Apache, and other techniques that would be time-consuming, and risk the "integrity" of configurations, develop environments, test environments, etc.
Well worth considering.
I adopted that as a regular tool for development and for normal networking.
I would try Relay Server (part of Afaria) which can re-direct mobile traffic based on profiles.
Update: tremoloqui's answer seems less trouble and far cheaper.
여기에 정답이 있습니다. 조금 더 많은 지식 : 이것들은 인증서 고정과 함께 작동하지 않습니다. (1) 도메인 와일드 카드 인증서를 사용하여 dev / test / qa 지역 테스트를 지원할 수 있습니다. 그리고 / 또는 (2) Apache와 같은 리버스 프록시 서버를 사용하여 Apache가 네트워크 내에서 요청을 라우팅하는 위치로 변경하십시오. 이제 SSL Pinning 테스트에 들어가면 물리적 장치로 수 중에서 사망하고 시뮬레이터 (ios) 및 에뮬레이터 (android)로만 유효성을 검사 할 수 있습니다.
참고 URL : https://stackoverflow.com/questions/6917107/how-can-i-redirect-http-requests-made-from-an-ipad
'IT박스' 카테고리의 다른 글
Gson이 "<"및 ">"를 유니 코드 이스케이프 시퀀스로 변환하는 것을 피할 수 있습니까? (0) | 2020.07.23 |
---|---|
jQuery datepicker는 선택된 날짜를 즉석에서 설정합니다. (0) | 2020.07.23 |
dom 렌더링이 완료된 후 지시문을 실행하려면 어떻게해야합니까? (0) | 2020.07.23 |
Angular.js 속성 지시문에 여러 속성을 어떻게 전달합니까? (0) | 2020.07.23 |
C #에서 상수 사전 만들기 (0) | 2020.07.23 |