Can I map an IP address like 127.0.0.1
to a domain name and a port?
For example, I would like to map 127.0.0.1
to api.example.com:8000
Can I map an IP address like 127.0.0.1
to a domain name and a port?
For example, I would like to map 127.0.0.1
to api.example.com:8000
No, that's not possible. The port is not part of the hostname, so it has no meaning in the hosts
-file.
If you really need to do this, use a reverse proxy. For example, with Nginx:
server {
listen api.mydomain.com:80;
server_name api.mydomain.com;
location / {
proxy_pass http://127.0.0.1:8000;
}
}
proxy_pass http://127.0.0.1:8000;
I got "invalid URL prefix" on nginx 1.4.3. –
Horsefaced © 2022 - 2024 — McMap. All rights reserved.
127.0.0.1 api.mydomain.com
and access it in the browser likeapi.mydomain.com:8080
– Witkowski