Wednesday, May 27, 2020

apache configuration

 Redirect Ip to domain 
 
RewriteEngine On
RewriteCond %{HTTP_HOST} ^100\.100\.45\.100
RewriteRule (.*) http://tech2towards.com/$1 [R=301,L]

Redirect port no to domain

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod lbmethod_byrequests
sudo systemctl restart apache2

#Setup the proxy

ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8081/
ProxyPassReverse / http://127.0.0.1:8081/

#Set_Proxy_For_Multiple_Path_on_Single_Domain

ProxyPreserveHost On
ProxyPass /Backend http://127.0.0.1:3000/
ProxyPassReverse /Backend http://127.0.0.1:3000/

<Proxy http://127.0.0.1:3000>
    Require all granted
    Options none
</Proxy>

---------------------------------------------------------------------------------

ProxyPreserveHost On
ProxyPass /Frontend http://127.0.0.1:4000/
ProxyPassReverse /Frontend http://127.0.0.1:4000/

<Proxy http://127.0.0.1:4000>
    Require all granted
    Options none
</Proxy>
 
Redirect HTTP to HTTPS
 
RewriteEngine on
RewriteCond %{SERVER_NAME} =tech2towards.tech
RewriteCond %{SERVER_NAME} =www.tech2towards.tech
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
 
RewriteEngine On
RewriteCond %{SERVER_PORT} !443
RewriteRule ^(/(.*))?$ https://%{HTTP_HOST}/$1 [R=301,L]
 
Redirect www to non-www in Apache
 
Add Below One In HTTPS virtual host


RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com [NC]
RewriteRule ^(.*)$ https://yourdomain.com$1 [L,R=301]

Only selected ip will be access the domain

<Location />
    Order deny,allow
    Deny from all
        Allow from 122.160.66.86
        Allow from 71.198.74.134
        Allow from 73.70.243.82
        Allow from 24.113.254.84
        Allow from 50.113.72.175
    </Location>
 
Allow Sub-directory Access

<Directory /var/www/html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
</Directory>

1 comment:

  1. ServerName example.io
    ServerAlias example.io www.example.io
    ServerAdmin webmaster@localhost

    Alias /blog /var/www/html/blog
    Alias /phpmyadmin /var/www/html/phpmyadmin


    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all



    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all


    ProxyPreserveHost On
    ProxyPassMatch ^/blog !
    ProxyPassMatch ^/phpmyadmin !
    ProxyPass / http://127.0.0.1:4036/
    ProxyPassReverse / http://127.0.0.1:4036/

    ReplyDelete

testing