Skip to content

Instantly share code, notes, and snippets.

@dangdungcntt
Last active March 27, 2024 15:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dangdungcntt/9f6c382e48e52f857142028e4ed32e08 to your computer and use it in GitHub Desktop.
Save dangdungcntt/9f6c382e48e52f857142028e4ed32e08 to your computer and use it in GitHub Desktop.
nginx-config-proxy-uptimerobot
server {
listen 80;
server_name status.nddcoder.com;
location / {
#proxy requests đến Uptimerobot
proxy_pass https://stats.uptimerobot.com/ojM8Acwzq/;
#Gửi server_name khi handshake SSL, nếu off thì sẽ bị lỗi SSL
proxy_ssl_server_name on;
#Set header này thì response trả về từ Uptimerobot không bị nén, từ đó mình có thể replace ở bước dưới
proxy_set_header Accept-Encoding "";
#Uptimerobot dùng header này với giá trị 'upgrade-insecure-requests' để trình duyệt luôn load các css/js với HTTPS. Ẩn header này để có thể truy cập vào status.nddcoder.com mà không cần HTTPS
proxy_hide_header Content-Security-Policy;
#Replace 1 số link trong response để website load tài nguyên, các nút trên giao diện hoạt động chính xác
sub_filter https://stats.uptimerobot.com/ojM8Acwzq /;
sub_filter https://stats.uptimerobot.com/ /;
#Xóa GTM để Uptimerobot không tracking được mình 😀
sub_filter '<script async src="https://www.googletagmanager.com/gtag/js?id=UA-1748433-46"></script>' '';
#Replace all
sub_filter_once off;
}
#Proxy assets requests
location /assets {
proxy_pass https://stats.uptimerobot.com/assets;
proxy_ssl_server_name on;
}
#Proxy api requests
location /api {
proxy_pass https://stats.uptimerobot.com/api;
proxy_ssl_server_name on;
}
}
# vim: syntax=nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment