Преглед на файлове

Merge pull request #47 from andreapollastri/develop

htaccess fix
Andrea Pollastri преди 5 години
родител
ревизия
fb6334d289
променени са 3 файла, в които са добавени 75 реда и са изтрити 58 реда
  1. 13 1
      go.sh
  2. 49 57
      storage/app/scripts/hostadd.sh
  3. 13 0
      storage/app/scripts/install.sh

+ 13 - 1
go.sh

@@ -7,9 +7,21 @@ echo "Wait..."
 sleep 3s
 echo -e "\n"
 
-sudo apt-get -y install dnsutils
+#ROOT Check
+if [ "$(id -u)" = "0" ]; then
+    clear
+    echo "Running as root :)"
+    sleep 6s
+    echo -e "\n"
+else
+    clear
+    echo "You have to run this script as root. In AWS digit 'sudo -s'"
+    echo -e "\n"
+    exit 1
+fi
 
 #VARS
+sudo apt-get -y install dnsutils
 IP=$(dig +short myip.opendns.com @resolver1.opendns.com)
 
 #START

+ 49 - 57
storage/app/scripts/hostadd.sh

@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
-DBROOT=???
-IP=???
+DBROOT=LLLe3y6iF3HNTyxwQbEsug5xsGlI32jqUFfLWuM73XNmIZ0m
+IP=3.10.203.14
 
 BASE_PATH=
 USER_SHELL=/bin/bash
@@ -80,46 +80,10 @@ mkdir /home/$USER_NAME/web/$BASE_PATH
 cat > "$CONF" <<EOF
 <VirtualHost *:80>
     ServerName $DOMAIN
-
         ServerAdmin webmaster@localhost
         DocumentRoot /home/$USER_NAME/web/$BASE_PATH
         ErrorLog /home/$USER_NAME/error.log
         CustomLog /home/$USER_NAME/access.log combined
-
-        Header always append X-Frame-Options SAMEORIGIN
-        Header set X-Content-Type-Options "nosniff"
-        Header set X-XSS-Protection "1; mode=block"
-        Header set X-Content-Security-Policy "allow 'self';"
-        Header edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure
-        TraceEnable off
-        FileETag None
-        ServerTokens Prod
-        ServerSignature Off
-
-        <IfModule mod_deflate.c>
-            <IfModule mod_headers.c>
-                Header append Vary User-Agent env=!dont-vary
-            </IfModule>
-            AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
-            <IfModule mod_mime.c>
-                AddOutputFilter DEFLATE js css htm html xml
-            </IfModule>
-        </IfModule>
-
-        <IfModule mod_expires.c>
-            ExpiresActive On
-            ExpiresByType image/jpeg						"access 1 year"
-            ExpiresByType image/jpeg						"access 1 year"
-            ExpiresByType image/gif							"access 1 year"
-            ExpiresByType image/png							"access 1 year"
-            ExpiresByType text/css							"access 1 month"
-            ExpiresByType application/pdf					"access 1 month"
-            ExpiresByType text/x-javascript					"access 1 month"
-            ExpiresByType application/x-shockwave-flash		"access 1 month"
-            ExpiresByType image/x-icon 						"access 1 year"
-            ExpiresDefault 									"access 2 days"
-        </IfModule>
-
         <Directory />
                 Order allow,deny
                 Options FollowSymLinks
@@ -139,24 +103,6 @@ cat > "$CONF" <<EOF
 </VirtualHost>
 EOF
 
-HTACCESS=/home/$USER_NAME/web/$BASE_PATH/.htaccess
-sudo touch $HTACCESS
-sudo cat > "$HTACCESS" <<EOF
-### APACHE SECURITY AND CACHING ###
-
-
-<IfModule mod_rewrite.c>
-RewriteEngine On
-RewriteBase /
-RewriteRule ^index\.php$ - [L]
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteCond %{REQUEST_FILENAME} !-d
-RewriteRule . /index.php [L]
-</IfModule>
-#############################
-EOF
-
-
 BASE=/home/$USER_NAME/web/$BASE_PATH/index.php
 sudo touch $BASE
 sudo cat > "$BASE" <<EOF
@@ -355,7 +301,6 @@ if [ "$AUTO_INSTALL" = "laravel" ]; then
     chmod 777 -R storage
 fi
 
-
 #WORDPRESS
 if [ "$AUTO_INSTALL" = "wordpress" ]; then
     cd /home/$USER_NAME/web/
@@ -397,6 +342,53 @@ EOF
     chmod 777 -R wordpress/wp-content/uploads/
 fi
 
+#CIPI CUSTOM HTACCESS
+HTACCESS=/home/$USER_NAME/web/$BASE_PATH/.htaccess
+sudo touch $HTACCESS
+sudo cat > "$HTACCESS" <<EOF
+Header always append X-Frame-Options SAMEORIGIN
+Header set X-Content-Type-Options "nosniff"
+Header set X-XSS-Protection "1; mode=block"
+Header set X-Content-Security-Policy "allow 'self';"
+
+<IfModule mod_deflate.c>
+    <IfModule mod_headers.c>
+        Header append Vary User-Agent env=!dont-vary
+    </IfModule>
+    AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
+    <IfModule mod_mime.c>
+        AddOutputFilter DEFLATE js css htm html xml
+    </IfModule>
+</IfModule>
+
+<IfModule mod_expires.c>
+    ExpiresActive On
+    ExpiresByType image/jpeg						"access 1 year"
+    ExpiresByType image/jpeg						"access 1 year"
+    ExpiresByType image/gif							"access 1 year"
+    ExpiresByType image/png							"access 1 year"
+    ExpiresByType text/css							"access 1 month"
+    ExpiresByType application/pdf					"access 1 month"
+    ExpiresByType text/x-javascript					"access 1 month"
+    ExpiresByType application/x-shockwave-flash		"access 1 month"
+    ExpiresByType image/x-icon 						"access 1 year"
+    ExpiresDefault 									"access 2 days"
+</IfModule>
+
+<IfModule mod_negotiation.c>
+    Options -MultiViews -Indexes
+</IfModule>
+
+RewriteEngine On
+RewriteCond %{HTTP:Authorization} .
+RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteCond %{REQUEST_URI} (.+)/$
+RewriteRule ^ %1 [L,R=301]
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule ^ index.php [L]
+EOF
 
 #GIT INIT
 if [ "$AUTO_INSTALL" = "git" ]; then

+ 13 - 0
storage/app/scripts/install.sh

@@ -14,6 +14,19 @@ DBPASS=???
 SERVERCODE=???
 REMOTEURL=???
 
+#ROOT Check
+if [ "$(id -u)" = "0" ]; then
+    clear
+    echo "Running as root :)"
+    sleep 6s
+    echo -e "\n"
+else
+    clear
+    echo "You have to run this script as root. In AWS digit 'sudo -s'"
+    echo -e "\n"
+    exit 1
+fi
+
 #REMOTE CURL
 curl --request GET --url $REMOTEURL/server/api/start/$SERVERCODE