Wednesday, April 18, 2018

Display Message and URL redirect using index.html

#
#
#
#
#

#
#Sorry! We have moved! The new URL is: http://http://www.example.com
#You will be redirected to the new address in five seconds.
#If you see this message for more than 5 seconds, please click on the link above!
#

#

RHEL7/CENTOS 7 custom apache on httpd.service


if httpd.service file is present then take backup  then add below line or else  if file not present  create a file httpd.service inside

 /usr/lib/systemd/system/httpd.service  and /usr/lib/systemd/httpd.service

add below parameter , i have installed my  Apache on /opt/apache2.2.34


[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)

[Service]
Type=forking
#EnvironmentFile=/etc/sysconfig/httpd
PIDFile=/opt/apache2.2.34/logs/httpd.pid
ExecStart=/opt/apache2.2.34/bin/apachectl -k start
ExecStop=/opt/apache2.2.34/bin/apachectl -k stop
ExecReload=/opt/apache2.2.34/bin/apachectl  -k graceful
#ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
#KillSignal=SIGCONT
PrivateTmp=true
LimitNOFILE=infinity

[Install]

WantedBy=multi-user.target

run below command:-

#systemctl daemon-reload

test your script by running

# service httpd stop
#service httpd start

#chkconfig httpd on 

if script is  complaining that  it cannot bind the port  80 or 443 kill or stop the apache running and test the script once again.

Saturday, January 6, 2018

Install Apache,php and Mongo DB drvier


I have installed below package before installing mongo


yum -y install httpd php
yum -y install php-pear.noarch
yum -y install  php-devel
yum -y install openssl-devel

Once all  dependence is  finished  run below command.



wget http://pecl.php.net/get/mongo
pecl install mongo-*.tgz

vi /etc/php.in

extension=mongo.so

restart Apache

service httpd restart

Convert cacert to pem


Run below command and enter  default password.
keytool -list -rfc -keystore cacerts > cacerts.pem

Sunday, April 23, 2017

Removing Xforward-ssl from Vary Header on Apache Webserver


If you insert any header for redirect  on your apache webserver then it will appear vary header.

RewriteCond %{HTTP:X-Forwarded-SSL} ^on$ [NC]
 RewriteRule ^/url.* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


eg .



  1. Content-Type:
    application/pdf
  2. Date:
    Sat, 22 Apr 2017 19:11:35 GMT
  3. Expires:
    Sun, 23 Apr 2017 19:11:35 GMT
  4. Keep-Alive:
    timeout=10, max=499
  5. Last-Modified:
    Thu, 19 Jan 2017 01:18:14 GMT
  6. Server:
    Apache
  7. Strict-Transport-Security:
    max-age=31536000; includeSubDomains
  8. Vary:
    X-Forwarded-SSL



This is ok if you don't have CDN ,since CDN don't like this header on vary, and you will have cache miss.

To over come this issue you need to make some changes on your Apache rewrite.

RewriteCond %{HTTP:X-Forwarded-SSL} ^on$ [NC,NV]
 RewriteRule ^/url.* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

NV is for no vary.

curl and cacert

curl -v --cacert cacert.pem https://www.example/cgi-bin/f ile.xgi -I -X POST