nginx.sh 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. #!/bin/bash
  2. clear
  3. if [[ "$EUID" -ne 0 ]]; then
  4. echo -e "\033[1;31mScript need to be run as root!\033[0m"; exit 1
  5. fi
  6. alamat_hos=$(cat /etc/environment | grep -w 'DOMAIN' | cut -d '=' -f 2)
  7. alamat_emel=$(cat /etc/environment | grep -w 'EMAIL' | cut -d '=' -f 2)
  8. apt-get -qq update
  9. apt-get install nginx -y
  10. mkdir /var/www/html/$alamat_hos
  11. mkdir /var/www/html/v2ray.$alamat_hos
  12. mkdir /var/www/html/xray.$alamat_hos
  13. cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
  14. cat > /etc/nginx/conf.d/cloudflare.conf <<-EOF
  15. set_real_ip_from 173.245.48.0/20;
  16. set_real_ip_from 103.21.244.0/22;
  17. set_real_ip_from 103.22.200.0/22;
  18. set_real_ip_from 103.31.4.0/22;
  19. set_real_ip_from 141.101.64.0/18;
  20. set_real_ip_from 108.162.192.0/18;
  21. set_real_ip_from 190.93.240.0/20;
  22. set_real_ip_from 188.114.96.0/20;
  23. set_real_ip_from 197.234.240.0/22;
  24. set_real_ip_from 198.41.128.0/17;
  25. set_real_ip_from 162.158.0.0/15;
  26. set_real_ip_from 104.16.0.0/13;
  27. set_real_ip_from 104.24.0.0/14;
  28. set_real_ip_from 172.64.0.0/13;
  29. set_real_ip_from 131.0.72.0/22;
  30. set_real_ip_from 2400:cb00::/32;
  31. set_real_ip_from 2606:4700::/32;
  32. set_real_ip_from 2803:f800::/32;
  33. set_real_ip_from 2405:b500::/32;
  34. set_real_ip_from 2405:8100::/32;
  35. set_real_ip_from 2a06:98c0::/29;
  36. set_real_ip_from 2c0f:f248::/32;
  37. real_ip_header CF-Connecting-IP;
  38. EOF
  39. echo '<!DOCTYPE html>
  40. <html lang="en">
  41. <head>
  42. <meta charset="UTF-8" />
  43. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  44. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  45. <title>Cybertize Devel</title>
  46. </head>
  47. <body>
  48. <main class="main">
  49. <section class="section">
  50. <article>
  51. <h3 class="article__title">
  52. <a href="/" class="title__link">CYBERTIZE</a>
  53. </h3>
  54. <p class="article_body">
  55. Use my referral link https://m.do.co/c/a28a40414d6a
  56. to gets $100 credit into your DigitalOcean account.
  57. Created by Doctype, Powered by Cybertize
  58. Copyright 2021, Allright reserved.
  59. </p>
  60. <p class="article__footer">
  61. Copyright &#169; 2021 Cybertize, All right reserved.
  62. </p>
  63. </article>
  64. </section>
  65. </main>
  66. </body>
  67. </html>' > /var/www/html/$alamat_hos/index.html
  68. echo '<!DOCTYPE html>
  69. <html lang="en">
  70. <head>
  71. <meta charset="UTF-8" />
  72. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  73. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  74. <title>Cybertize Devel</title>
  75. </head>
  76. <body>
  77. <main class="main">
  78. <section class="section">
  79. <article>
  80. <h3 class="article__title">
  81. <a href="/" class="title__link">CYBERTIZE</a>
  82. </h3>
  83. <p class="article_body">
  84. Use my referral link https://m.do.co/c/a28a40414d6a
  85. to gets $100 credit into your DigitalOcean account.
  86. Created by Doctype, Powered by Cybertize
  87. Copyright 2021, Allright reserved.
  88. </p>
  89. <p class="article__footer">
  90. Copyright &#169; 2021 Cybertize, All right reserved.
  91. </p>
  92. </article>
  93. </section>
  94. </main>
  95. </body>
  96. </html>' > /var/www/html/v2ray.$alamat_hos/index.html
  97. echo '<!DOCTYPE html>
  98. <html lang="en">
  99. <head>
  100. <meta charset="UTF-8" />
  101. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  102. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  103. <title>Cybertize Devel</title>
  104. </head>
  105. <body>
  106. <main class="main">
  107. <section class="section">
  108. <article>
  109. <h3 class="article__title">
  110. <a href="/" class="title__link">CYBERTIZE</a>
  111. </h3>
  112. <p class="article_body">
  113. Use my referral link https://m.do.co/c/a28a40414d6a
  114. to gets $100 credit into your DigitalOcean account.
  115. Created by Doctype, Powered by Cybertize
  116. Copyright 2021, Allright reserved.
  117. </p>
  118. <p class="article__footer">
  119. Copyright &#169; 2021 Cybertize, All right reserved.
  120. </p>
  121. </article>
  122. </section>
  123. </main>
  124. </body>
  125. </html>' > /var/www/html/xray.$alamat_hos/index.html
  126. chown -R www-data:www-data /var/www/html/$alamat_hos
  127. chown -R www-data:www-data /var/www/html/v2ray.$alamat_hos
  128. chown -R www-data:www-data /var/www/html/xray.$alamat_hos
  129. echo "server {
  130. listen 80;
  131. listen [::]:80;
  132. root /var/www/html/$alamat_hos;
  133. index index.html index.htm;
  134. server_name $alamat_hos;
  135. location / {
  136. try_files \$uri \$uri/ =404;
  137. }
  138. }" > /etc/nginx/sites-available/$alamat_hos.conf
  139. echo "server {
  140. listen 80;
  141. listen [::]:80;
  142. root /var/www/html/v2ray.$alamat_hos;
  143. index index.html index.htm;
  144. server_name v2ray.$alamat_hos;
  145. location / {
  146. try_files \$uri \$uri/ =404;
  147. }
  148. }" > /etc/nginx/sites-available/v2ray.$alamat_hos.conf
  149. echo "server {
  150. listen 80;
  151. listen [::]:80;
  152. root /var/www/html/xray.$alamat_hos;
  153. index index.html index.htm;
  154. server_name xray.$alamat_hos;
  155. location / {
  156. try_files \$uri \$uri/ =404;
  157. }
  158. }" > /etc/nginx/sites-available/xray.$alamat_hos.conf
  159. ln -s /etc/nginx/sites-available/$alamat_hos.conf /etc/nginx/sites-enabled/
  160. ln -s /etc/nginx/sites-available/v2ray.$alamat_hos.conf /etc/nginx/sites-enabled/
  161. ln -s /etc/nginx/sites-available/xray.$alamat_hos.conf /etc/nginx/sites-enabled/
  162. apt-get -y -qq install certbot
  163. apt-get -y -qq install python3-certbot
  164. apt-get -y -qq install python3-certbot-nginx
  165. certbot --non-interactive --agree-tos --email $alamat_emel --nginx -d $alamat_hos -d www.$alamat_hos
  166. certbot --non-interactive --agree-tos --email $alamat_emel --nginx -d v2ray.$alamat_hos
  167. certbot --non-interactive --agree-tos --email $alamat_emel --nginx -d xray.$alamat_hos
  168. echo '10 11 * * * root /usr/bin/certbot renew >/dev/null 2>&1' >> /etc/crontab
  169. nginx -t && systemctl restart nginx
  170. echo
  171. echo -e "\033[1;32mTahniah, Kami telah selesai dengan pemasangan nginx.\033[0m"
  172. echo
  173. echo 'Use my referral link https://m.do.co/c/a28a40414d6a'
  174. echo 'to gets $100 credit into your DigitalOcean account.'
  175. echo
  176. echo 'Hak Cipta 2021 Doctype, Dikuasakan oleh Cybertize.'
  177. sleep 5