35 lines
1.1 KiB
Markdown
35 lines
1.1 KiB
Markdown
|
# MyIP.Coffee
|
||
|
|
||
|
MyIP.Coffee is a simple web service that returns the IP address of the client making the request.
|
||
|
|
||
|
## Setup
|
||
|
|
||
|
There are two components to this project, the website and the endpoint that returns the IP address.
|
||
|
|
||
|
The endpoint runs on https://ipv4.myip.coffee and https://ipv6.myip.coffee. The IPv4 endpoint only has an A record, while the IPv6 endpoint has both only an AAAA record.
|
||
|
|
||
|
### nginx
|
||
|
|
||
|
If you use nginx, you don't need the endpoint. You can use the following configuration to return the IP address of the client:
|
||
|
|
||
|
```nginx
|
||
|
server {
|
||
|
listen 80;
|
||
|
listen [::]:80;
|
||
|
|
||
|
server_name ipv4.myip.coffee ipv6.myip.coffee;
|
||
|
|
||
|
location / {
|
||
|
return 200 "$remote_addr";
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
### PHP
|
||
|
|
||
|
As our web hosting solution comes with PHP, there is a PHP script in [endpoint/index.php](endpoint/index.php) that just returns the IP address of the client. It is trivial to implement this in other languages, so this is left as an exercise to the reader.
|
||
|
|
||
|
## License
|
||
|
|
||
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|