Skip to main content

Posts

htaccess redirection / passwd subfolder problem

Sometimes when we need to put htaccess password or redirection in the subfolders of a site like /home/user/public_html/SVT/VVT/.htaccess. In this case there is a possiblity of .htaccesss is not getting picked by apache.. For making apache to read the subfolder .htaccess file put the below line in the first of the htaccess file. ErrorDocument 401 "Unauthorized". So the .htaccess file for password protection will be as follows: ErrorDocument 401 "Unauthorized" AuthUserFile /home/username/public_html/SVT/VVT/.htpasswd AuthType Basic AuthName "Password Protected Area" Require valid-user

Internal Server Error + uWsgi + Python (While Updating Ubuntu from 16.04 to 18.04)

When I tried to upgrade my APP server from Ubuntu 16.04 to 18.04 with Python Django application after upgrade Python virtual env is giving the below error for the ./manage.py runserver command. " ImportError: cannot import name _remove_dead_weakref" For solving this error I have done the below fix: cd my-virtualenv-directory virtualenv . --system-site-packages The option --system-site-packages was needed because the application uses python-gtk from Ubuntu. I gues in most other cases it is not needed. Now after that the first error had gone and the below came up: ImportError: /environment-path/virt-env/local/lib/python2.7/site-packages/lxml/etree.so: undefined symbol: PyFPE_jbuf For solving this error I have done the below fix: sudo pip install --upgrade pyOpenSSL cryptography sudo pip uninstall lxml (Optional if needed only lxml is installed) sudo rm -rf /environment-path/virt-env//local/lib/python2.7/site-packages/lxml /environment-path/virt-env//local/li...

Configuring NAXSI WebApplicationFirewall with NGINX & Ubuntu 18.04

 Initial Setup: ########### Nginx latest version installed : 1.14.0 Steps: ##### apt update apt install libpcre3-dev libssl-dev unzip build-essential daemon libxml2-dev libxslt1-dev libgd-dev libgeoip-dev Download and unzip naxis. wget https://github.com/nbs-system/naxsi/archive/master.zip unzip master.zip wget http://nginx.org/download/nginx-1.14.0.tar.gz;tar -xzvf nginx-1.14.0.tar.gz Now cd to the downloaded and untar'ed Nginx package directory. cd nginx-1.14.0 ./configure --conf-path=/etc/nginx/nginx.conf --add-module=../naxsi-master/naxsi_src/ --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --us...

Setting up S3cmd client to manage files in Digital Ocean.

First we need to generate the Token , KEY ID and Secret key from the Digital ocean console > API > Generate Token > Generate Key. Installation In Centos ###################### cd /etc/yum.repos.d wget http://s3tools.org/repo/RHEL_6/s3tools.repo yum install s3cmd Configuring the S3cmd ##################### s3cmd --configure This will ask for Key Id and Secret Key Region use the default one. No encripytion is necessary, just enter. Say yes for ssl https and finally press enter of HTTP Proxy Now the confiurations will be saved in the ~/.s3cfg file. Open it and add the below entries: access_token = host_base = <region>.digitaloceanspaces.com host_bucket = %(bucket)s.<region> .digitaloceanspaces.com now save the file and exit. Putting a file to Digitial Ocean bucket. ######################################## s3cmd put /home/jino/filetest.txt s3:// <bucket> Reference. ######### https://www.digitalocean.com/docs/api/example-...

Extending Your EBS Volume in Linux AWS EC2

First you have to select the EBS volume >> Actions >> Modify Volume . Now select the total volume that you want to increase to in the size section. Now click on the Modify button. Now finally do the below steps after login to the server for extending the additionally allocated space. # df -h  >> This will show you the Filesystem like '/dev/xvda1'. Expand the modified partition using  growpart  (note that you need to add a space between the device name and the partition number): # sudo  growpart /dev/xvda 1  # sudo growpart /dev/nvme0n1 1  >> for /dev/nvme0n1p1 A look at the  lsblk  output confirms that the partition  /dev/xvda1  now fills the available space on the volume: #  root@logserver:~# lsblk NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda    202:0    0  40G  0 disk  └─xvda1 202:1    0  40G  0 part / To ex...

Generating SSL Certificate with Namecheap and ELB assigning using ACM

First Generate a Private Key for SSL: This I am doing from the web server. # openssl genrsa -out gateway_key.pem 2048 Now generate a csr with using the above key: # root@ip-10-0-3-90:~# openssl req -new -sha256 -key gateway_key.pem -out gateway_key.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:JP State or Province Name (full name) [Some-State]:XXXX Locality Name (eg, city) []:XXXX Organization Name (eg, company) [Internet Widgits Pty Ltd]:XXXX Co Ltd Organizational Unit Name (eg, section) []:XXXX Common Name (e.g. server FQDN or YOUR name) []:gateway.X-XXXX.net Email Address []:admin@X-XXXX.net Please enter the following 'extr...

Setting up Additional IP address to an EC2 Instance.

Suppose you want to add an additional IP to your Ubuntu Web Server, Here the steps are as follows: 1) Make sure your EC2 instance type will support more than 2 Network Interfaces. If not then you have to upgrade your Instance Type. 2) Add a New Network Interface. Make sure you give the same AZ, Subnet and Security Group as of the web server. 3) Now Add an Elastic IP and associate this elastic ip to the Web server. 4) Now attach the new Network Interface to the Webserver. Now the final part is , to create 2 route tables with default routes for each interface and use rules on inbound traffic to assign which table to use for the response traffic. 5) Here is a sample interface file that performs this: root@webserver:~# cat /etc/network/interfaces.d/eth0.cfg auto eth0 iface eth0 inet dhcp post-up ip route add default via 10.0.1.1 dev eth0 tab 1 post-up ip rule add from 10.0.1.81 tab 1 pre-down ip rule del from 10.0.1.81 tab 1 pre-down ip route del default via 10.0.1.1 dev ...