Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #---------------------------------------------------- Task 1 IPgeolacation-api --------------------------------------------#
- [ec2-user@ip-172-31-41-59 ~]$
- [ec2-user@ip-172-31-41-59 ~]$
- [ec2-user@ip-172-31-41-59 ~]$ docker network create ip-net
- 678148d6ccb2d7fbf1ef323371d5df9e6fb9a5d79a6f97a4c452d69394deb99a
- [ec2-user@ip-172-31-41-59 ~]$
- [ec2-user@ip-172-31-41-59 ~]$
- [ec2-user@ip-172-31-41-59 ~]$ docker container run \
- > --name redis \
- > --restart always \
- > --network ip-net \
- > -d \
- > redis:latest
- Unable to find image 'redis:latest' locally
- latest: Pulling from library/redis
- [ec2-user@ip-172-31-41-59 ~]$ docker container run \
- > --name ip-api1 \
- > --network ip-net \
- > --restart always \
- > -d \
- > -e REDIS_PORT="6379" \
- > -e REDIS_HOST="redis" \
- > -e APP_PORT="8080" \
- > -e API_KEY="48c444472b0840848c261f62abe32b0d" \
- > fujikomalan/ipgeolocation-api-service
- 37ba7046fedfec3f7b5095d04aaf386cd5fe133ff3b957e51b5657dc0753d40b
- [ec2-user@ip-172-31-41-59 ~]$
- [ec2-user@ip-172-31-41-59 ~]$
- [ec2-user@ip-172-31-41-59 ~]$ docker container run --name ip-api2 --network ip-net --restart always -d -e REDIS_PORT="6379" -e REDIS_HOST="redis" -e APP_PORT="8080" -e API_KEY="48c444472b0840848c261f62abe32b0d" fujikomalan/ipgeolocation-api-service
- 258848e736a156b5d87d7cdb816cc0fc78fcfacd43bb0e09a9147ca9613da2aa
- [ec2-user@ip-172-31-41-59 ~]$
- [ec2-user@ip-172-31-41-59 ~]$
- [ec2-user@ip-172-31-41-59 ~]$
- [ec2-user@ip-172-31-41-59 ~]$ docker container run --name ip-api3 --network ip-net --restart always -d -e REDIS_PORT="6379" -e REDIS_HOST="redis" -e APP_PORT="8080" -e API_KEY="48c444472b0840848c261f62abe32b0d" fujikomalan/ipgeolocation-api-service
- be25e445c1adfbe576e74b983221d5011f2dd51450bce2c9b3fdeef2337be4bf
- [ec2-user@ip-172-31-41-59 ~]$
- #---------------------------------------------------- Task 1.1 nginx container --------------------------------------------#
- [______________________________________________SSL from freessl.org_________________________________________]
- [ec2-user@ip-172-31-41-59 certs]$ cat ipgeolocation.chrisich.fun.pem intermediate.pem root.pem > ssl.crt
- [ec2-user@ip-172-31-41-59 certs]$
- [ec2-user@ip-172-31-41-59 certs]$
- [ec2-user@ip-172-31-41-59 certs]$ mv ipgeolocation.chrisich.fun.key ssl.key
- [ec2-user@ip-172-31-41-59 certs]$ ll
- total 32
- -rwxr-xr-x. 1 ec2-user ec2-user 4041 Jun 3 08:53 intermediate.pem
- -rwxr-xr-x. 1 ec2-user ec2-user 6103 Jun 3 08:53 ipgeolocation.chrisich.fun.pem
- -rwxr-xr-x. 1 ec2-user ec2-user 2093 Jun 3 08:53 root.pem
- -rw-r--r--. 1 ec2-user ec2-user 12237 Jun 3 08:57 ssl.crt
- -rwxr-xr-x. 1 ec2-user ec2-user 1732 Jun 3 08:53 ssl.key
- [ec2-user@ip-172-31-41-59 ssl]$ cat default.conf
- server {
- listen 80;
- listen [::]:80;
- return 301 https://$host$request_uri;
- server_name ipgeolocation.chrisich.fun;
- }
- server {
- listen 443 ssl;
- server_name ipgeolocation.chrisich.fun;
- ssl_certificate /etc/nginx/cert/ssl.crt;
- ssl_certificate_key /etc/nginx/cert/ssl.key;
- location / {
- proxy_pass http://flaskapps;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto $scheme;
- }
- }
- upstream flaskapps{
- server ip-api1:8080;
- server ip-api2:8080;
- server ip-api3:8080;
- }
- [ec2-user@ip-172-31-41-59 ssl]$ docker container run \
- > --name nginx \
- > --restart always \
- > --network ip-net \
- > -p 80:80 -p 443:443 \
- > -d \
- > -v $(pwd)/default.conf:/etc/nginx/conf.d/default.conf \
- > -v $(pwd)/certs/:/etch/nginx/cert/ \
- > nginx:latest
- [ec2-user@ip-172-31-41-59 ssl]$ docker container ls -a
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- 81b5ce908a89 nginx:latest "/docker-entrypoint.…" 22 minutes ago Up 22 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp nginx
- be25e445c1ad fujikomalan/ipgeolocation-api-service "python3 app.py" About an hour ago Up About an hour 8080/tcp ip-api3
- 258848e736a1 fujikomalan/ipgeolocation-api-service "python3 app.py" About an hour ago Up About an hour 8080/tcp ip-api2
- 37ba7046fedf fujikomalan/ipgeolocation-api-service "python3 app.py" 2 hours ago Up 2 hours 8080/tcp ip-api1
- 3d95675a1e56 redis:latest "docker-entrypoint.s…" 2 hours ago Up 2 hours 6379/tcp redis
- #---------------------------------------------------- Task 2 Redsis-cli --------------------------------------------#
- [ec2-user@ip-172-31-41-59 ssl]$ docker container exec redis cat /etc/os-release
- PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
- NAME="Debian GNU/Linux"
- VERSION_ID="11"
- VERSION="11 (bullseye)"
- VERSION_CODENAME=bullseye
- ID=debian
- HOME_URL="https://www.debian.org/"
- SUPPORT_URL="https://www.debian.org/support"
- BUG_REPORT_URL="https://bugs.debian.org/"
- [ec2-user@ip-172-31-41-59 ssl]$
- [ec2-user@ip-172-31-41-59 ssl]$
- [ec2-user@ip-172-31-41-59 ssl]$ docker container exec -it redis bash
- root@3d95675a1e56:/data#
- root@3d95675a1e56:/data#
- root@3d95675a1e56:/data# redis-cli
- 127.0.0.1:6379>
- 127.0.0.1:6379>
- 127.0.0.1:6379>
- 127.0.0.1:6379> KEYS * [List all the keys]
- 1) "9.9.9.9"
- 2) "1.1.1.1"
- 127.0.0.1:6379>
- 127.0.0.1:6379>
- 127.0.0.1:6379> GET 9.9.9.9 [showing one key value]
- "{\"ip\": \"9.9.9.9\", \"continent_code\": \"EU\", \"continent_name\": \"Europe\", \"country_code2\": \"CH\", \"country_code3\": \"CHE\", \"country_name\": \"Switzerland\", \"country_capital\": \"Bern\", \"state_prov\": \"Zurich\", \"state_code\": \"CH-ZH\", \"district\": \"\", \"city\": \"Zurich\", \"zipcode\": \"8004\", \"latitude\": \"47.37328\", \"longitude\": \"8.53113\", \"is_eu\": false, \"calling_code\": \"+41\", \"country_tld\": \".ch\", \"languages\": \"de-CH,fr-CH,it-CH,rm\", \"country_flag\": \"https://ipgeolocation.io/static/flags/ch_64.png\", \"geoname_id\": 12003391, \"isp\": \"Quad9\", \"connection_type\": \"\", \"organization\": \"Quad9\", \"currency\": {\"code\": \"CHF\", \"name\": \"Swiss Franc\", \"symbol\": \"CHF\"}, \"time_zone\": {\"name\": \"Europe/Zurich\", \"offset\": 1, \"current_time\": \"2023-06-03 11:24:53.733+0200\", \"current_time_unix\": 1685784293.733, \"is_dst\": true, \"dst_savings\": 1}, \"cached\": \"False\", \"apiServer\": \"37ba7046fedf\"}"
- 127.0.0.1:6379>
- 127.0.0.1:6379> DEL 9.9.9.9 [Deleting one key value]
- (integer) 1
- 127.0.0.1:6379>
- 127.0.0.1:6379> KEYS *
- 1) "1.1.1.1
- "127.0.0.1:6379>
- 127.0.0.1:6379>
- 127.0.0.1:6379> FLUSHALL [Flushing all keys]
- OK
- 127.0.0.1:6379>
- 127.0.0.1:6379> KEYS *
- (empty array)
Advertisement
Add Comment
Please, Sign In to add comment