Bad Request (Invalid Hostname) when accessing via IP

Customer wanted to have a dedicated IP, but once I change the IP from the plesk control panel, I couldn’t get the website when accessed using IP. Instead, it was giving me the plesk control panel’s default page. Reason ? Default Website was having the IP as “All Unassigned”. Set that to the main IP address. But after that I was getting a new error.

What I could get was “Bad Request (Invalid Hostname)” in bold letters. Here is what I did to fix the same.

Start -> Run -> inetmgr -> Expand the (+) -> Websites -> Right click on the domain name -> Take Properties -> Website -> IP Address (make sure that it has the dedicated IP assigned there) and then click “Advanced”

Add/Edit Web Site Identification

IP Address : Choose the dedicated IP from drop down list
TCP/IP Port : 80
Host Header Value : Leave it blank (Important)

Leaving the Host Header Value should fix the issue and fetch the website when accessing it using the IP.

Continue Reading

Rebuilding Software RAID

One of our clients had a hard drive fail. The harddisk was marked faulty and removed as well. Client inserted new HDDs, and needed us to rebuild the array. Hot swappable HDs would have done the job real quick. But not here. There is some process involved in rebuilding the array.

A normal array will have the output similar to below – Notice the [UU] – U could mean “Used”. A fully functional RAID system would show [UU] for each slice.


cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[0] sdb1[1]
1052160 blocks [2/2] [UU]

A degraded array will look like,

cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdb2[1]
8385856 blocks [2/1] [_U]

_ means degraded array i.e partition missing from array.

Use fdisk to create partitions similar to the one working in the HDD. Using fdisk, then n , p t etc to recreate the partitions are not needed if you have sfdisk in the server.

sfdisk – Partition table manipulator for Linux

fdisk -l or cat /proc/mdstat will give you the device name which is active and the below command will give the partition table of sdb to part.sdb file

sfdisk -d /dev/sdb > part.sdb

sfdisk –-force /dev/sda < part.sdb will copy the partition table to this new sda disk saving the time.

BE CAREFUL ON WHAT PARTITION TABLES ARE COPIED. Don't copy unused drive's partition table to the active one :D

Finally, once the partition table is copied, execute this

# mdadm --add /dev/md0 /dev/sda1
# mdadm --add /dev/md1 /dev/sda3
# mdadm --add /dev/md2 /dev/sda2
# mdadm --add /dev/md3 /dev/sda5

Continue Reading

Enabling mod_rewrite in Apache 2.2

By default CentOS or RHEL flavours of Linux has Apache 2.2 installed. It often becomes a requirement to enable mod_rewrite on these servers. Techs who have been working with cPanel and server with control panels often finds it difficult to troubleshoot issues with a bare server. There are a few things to check or commands to execute in such case where mod_rewrite is shown enabled in the httpd.conf, but not working.

[root@cave html]# httpd -V
Server version: Apache/2.2.3

[root@cave html]# httpd -M
Loaded Modules:
core_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
auth_basic_module (shared)
auth_digest_module (shared)
….
…….
….
rewrite_module (shared)
proxy_module (shared)
proxy_balancer_module (shared)
proxy_ftp_module (shared)
proxy_http_module (shared)
proxy_connect_module (shared)

[root@cave html]# a2enmod rewrite

a2enmod is only to be used if the rewrite_module is not enabled in httpd.conf

Check for the “AllowOverride” settings. It should be set to “All“. By default it will be “None

Things should work fine after this. Also I found a small good script to check at this URL to see whether mod_rewrite is enabled or not http://www.webune.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html

Good Luck guys!

Continue Reading

Magento Suhosin Values

Sometimes Magento admins face the issue of some values missing from the frontend even though the configuration would have shown to be saved from Backend. This could be due the limit in the number of values set by suhosin.

The common override for this issue is to have the following values set in .htaccess

php_value suhosin.mail.protect 0
php_value suhosin.memory_limit 128M
php_value suhosin.post.max_vars 5000
php_value suhosin.post.max_value_length 500000
php_value suhosin.request.max_vars 5000
php_value suhosin.request.max_value_length 500000
php_flag suhosin.session.cryptua off

For php.ini use the variables without php_value or php_flag

Continue Reading

How to redirect non ssl (http links) traffic to SSL (https links)

Our Level I techs often gets tickets like how to make http:// or http://www. redirect to https:// or https://www. Often the answer is simple, but for the newbies and yours use, I am putting it here.

First requirement is to have an SSL certificate installed. Add the following lines in a .htaccess file:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

I assume when you directly access https://www.domainname.com , the site loads fine.

Continue Reading


 

About this blog

This blog, acts as a knowledge repository for the world and is unofficial! Anything we find interesting in the cyber world will go here. Most cases, this blog will reflect the happiness of our staff in reaching successful solution to an issue (s)he worked on. A reference for other fellow SAGEs who come across similar issues later