facelordgists
2/25/2019 - 8:05 PM

curl tips & tricks

Curl a website from one server to another within a private network, such as a gateway to appserver or loadbalancer to appserver.

# -H sets the header
# -v includes the header information
# /dev/null pipes the contents of the page output into a blackhole
curl -v http://<server-host_or_ip>/ -H "Host: domain.com" > /dev/null

# Example
curl -v https://localhost/ -H "Host: www.dentalmanagers.com" > /dev/null
curl -v http://appserver-4/ -H "Host: www.1111dental.com" > /dev/null
curl -v http://appserver-4/ -H "Host: test.roadsidedentalmarketing.com" > /dev/null

# View the HTML output
curl -v https://localhost/ -H "Host: www.dentalmanagers.com" | less

# Connect to loadbalancer (use HTTPS directly)
# Use HTTPS protocol, bypass cache
curl -v https://loadbalancer-production-alpha-1/ -H "Host: test.roadsidedentalmarketing.com" -H "X-Forwarded-Proto: https" -H "X-Cache-Bypass: true" --insecure  > /dev/null
## see html returned
curl -v https://loadbalancer-production-alpha-1/ -H "Host: test.roadsidedentalmarketing.com" -H "X-Forwarded-Proto: https" -H "X-Cache-Bypass: true" --insecure  | less

# Connect to app server using http with https added as a header
curl -v http://akkala-4/ -H "Host: test.roadsidedentalmarketing.com" -H "X-Forwarded-Proto: https" -H "X-Cache-Bypass: true" > /dev/null
## see html returned
curl -v http://akkala-4/ -H "Host: test.roadsidedentalmarketing.com" -H "X-Forwarded-Proto: https" -H "X-Cache-Bypass: true" | less