장치를 Mac localhost 서버에 연결 하시겠습니까? [닫은]
iPhone과 같은 장치가 WLAN을 통해 Mac의 로컬 호스트 서버에 연결되도록하려면 어떻게해야합니까?
내 Mac 에서는 Safari에서 성공적으로 열리는 페이지를 제공하는 "Hello World"HTTP Node.js 서버를 http://localhost:1337
. 그리고 ipconfig getifaddr en1
터미널 에서 실행하면 192.168.1.9
.
그러나 Safari는 iPhone과 Mac 모두에서을 열려고 할 때 "Safari에서 서버에 연결할 수 없습니다"라고 표시됩니다 http://192.168.1.9:1337
.
HTTP 서버를 공개적으로 사용하지 않고 비공개로만 사용할 수 있기를 원하기 때문에 이것이 포트 포워딩을 포함해서는 안된다고 생각합니다 .
관련 :
- iPhone에서 로컬 호스트에 액세스 (동일한 네트워크에서)
- https://superuser.com/questions/308451/connect-to-localhost-from-another-computer
- https://superuser.com/questions/400752/can-we-run-local-server-over-local-network-without-internet-access
- https://serverfault.com/questions/254947/accessing-localhost-xampp-from-another-computer-over-lan-network-how-to
나는 같은 문제가 있었다. Mac에서 WI-FI를 껐다가 다시 켜서 문제가 해결되었습니다. 설정> Wi-FI 끄기를 클릭합니다.
iPhone에서 Safari로 이동하여 호스트 이름 또는 IP 주소를 입력하여 테스트했습니다. 예 : http://<name>.local
또는http://10.0.1.5
서버가 수신 대기이 192.168.1.9:1337
아니라 localhost:1337
, 예 127.0.0.1:1337
.
을 사용해서 만 iPhone에 액세스 할 수있었습니다 http://name.local:1337
. ".local"을 추가해야합니다. 시스템 환경 설정 / 공유 / "컴퓨터 이름"에서 컴퓨터 이름을 찾을 수 있습니다.
인터넷 공유 활성화 :
시스템 환경 설정-> 공유를 엽니 다. 인터넷 공유를 확인하여 켜면 작업을 확인하라는 메시지가 표시되고 확인을 선택합니다. iPhone이 USB를 사용하여 연결된 경우 오른쪽의 "연결 공유"목록에서 iPhone USB가 선택됩니다.
그런 다음 wifi에서 macs ip를 사용하여 로컬 서버에 액세스하십시오.
내 문제는 같았지만 해결책은 방화벽 설정 변경과 관련이 있습니다. 노드가 들어오는 트래픽을 차단하도록 설정되었습니다. 내 전화에서 내 로컬 호스트 서버에 액세스 할 수 있었기 때문에 문제가 발생했음을 알았습니다.
이동 시스템 환경 설정 -> 보안 및 개인 정보 보호 정책 -> 방화벽 -> 방화벽 옵션 , 당신이 찾을 때까지 아래로 스크롤 노드를 하고 있는지 노드의 설정이 설정되어 있는지 확인 들어오는 연결을 허용합니다 .
설정을 변경 한 후 http://192.168.1.11:3000 으로 이동하여 Mac에서 실행중인 로컬 호스트 서버 (포트 3000)에 연결할 수 있습니다.
비슷한 문제를 해결합니다.
- Mac과 iPhone을 동일한 Wi-Fi에 연결
- iPhone Wi-Fi 설정을 변경하고 http 프록시를 수동으로 설정하고 서버를 Mac IP 주소로 변경하고 포트를 설정하십시오. 내 포트는 80입니다.
http://<Mac ip>:<your customer server port>
iPhone의 사파리에 입력 할 수 있습니다.
MacOS Sierra users can find their auto-generated vanity URL by going to System Preferences > Sharing
and checking beneath the Computer Name text input. To access it, enter this URL, plus your port number (e.g. your-name.local:8000), on your iPhone over the same Wi-Fi connection as your computer.
I suggest to use the name of the computer, e.g.http://mymac:1337/
. Works for me perfect without any configuration required and I don't have to care about changing IP addresses due DHCP.
make sure you phone and mac machine both connected to the same wifi and you good to go your http://<machine-name>.local
As posted I followed moeamaya's answer but needed to modify it just a bit to see my work in the Sites directory.
http://[name].local.~[username]/
[name] is as stated already (System Preferences/sharing/"Computer Name")
[username] is found at:
/etc/apache2/users/username.conf
hope this helps!
Connect your iPhone to your Mac via USB.
Go to Network Utility (cmd+space and type "network utility")
Go to the "Info" tab
Click on the drop down menu that says "Wi-Fi" and select "iPhone USB" as shown here:
You'll find an IP address like "xxx.xxx.xx.xx" or similar. Open Safari browser on your iPhone and enter IP_address:port_number
Example: 169.254.72.86:3000
[NOTE: If the IP address field is blank, make sure your iPhone is connected via USB, quit Network Utility, open it again and check for the IP address.]
Tried everything on this page, but http://<name>.local:<PORT>
only worked on my iPhone after I quit and restarted Safari...
Always use the IP that is shown in your Network settings. It changes when you change location and you use another wireless connection.
예를 들어 제 경우에는 10.0.0.5입니다.
또한 서버가 모바일 장치를 듣고 있는지 확인하십시오! 예를 들어, 기본적으로 jekyll은 호스트 시스템의 요청에만 응답합니다. 이것은 내 문제를 해결했습니다.
LAN에서 모바일 장치를 사용하여 로컬로 구축 된 Jekyll Server에 연결
참고 URL : https://stackoverflow.com/questions/12657651/connect-device-to-mac-localhost-server
'developer tip' 카테고리의 다른 글
/ etc / nginx를 어떻게 복원 할 수 있습니까? (0) | 2020.09.13 |
---|---|
Mocha API 테스트 : 'TypeError : app.address is not a function'발생 (0) | 2020.09.13 |
Visual Studio 코드 CSS 들여 쓰기 및 서식 (0) | 2020.09.12 |
Elmah에서 이메일을 보내시겠습니까? (0) | 2020.09.12 |
요청 속성으로 사용할 수있는 빈 이름에 대한 BindingResult 또는 일반 대상 개체가 없습니다. [duplicate] (0) | 2020.09.12 |