Selectively allow http access to some folders

Discussion in 'General' started by thx2000, Mar 29, 2009.

  1. thx2000

    Joined:
    Mar 28, 2009
    Messages:
    19
    Likes Received:
    0
    HTTPS isn't too friendly with some hardware and software. Here's a trick to selectively allow a folder, or folders, to be accessed via http and not redirected to https.

    [*]edit /etc/httpd/conf/httpd.conf and look for the following:
    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    
    [*]Change it to the following to allow http access to both the 'aastra' and 'http' folders in '/var/www/html/'.
    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_URI} !(/http/*)
    RewriteCond %{REQUEST_URI} !(/aastra/*)
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    
    [*]Of course, you can copy this example to add several folders to be https exempt, or you could change 'RewriteEngine On' to 'RewriteEngine Off' and disable the redirection all together. However if you create the 'http' directory in '/var/www/html/' anything you drop in it will no longer be redirected to https

    -THX2000
     
  2. trigremm

    Joined:
    Aug 13, 2010
    Messages:
    6
    Likes Received:
    0
    want to add
    in some elastix versions it is useful to look for /etc/httpd/conf.d/elastix.conf file
    ;)
     
  3. gl1176

    Joined:
    Oct 5, 2009
    Messages:
    55
    Likes Received:
    0
    Yes, a better way to do this is adding lines for each directory to /etc/httpd/conf.d/elastix.conf like this:


    <Directory "/var/www/html/xmlservices">
    RewriteEngine Off
    </Directory>

    and then reload apache:

    service httpd restart
     
  4. johnme

    Joined:
    Nov 28, 2008
    Messages:
    148
    Likes Received:
    0
    Hi

    How can we have access in a folder for example /var/www/html/a_program

    in another port and mabe another ip address?

    I have created a virtual ip under my real ip and a virtual host at the same port 443.
    But the problem is that it works partial.

    When i try to login with the virtual address i have the message for ssl in firefox, i install the ssl and then it redirect me to the real internal ip.
    When i try it from outside (internet) it is worst, i get redirected to the real internal ip and i can't see anything.

    The point is to make a program works on his own port. So i will open that port on my firewall and have access only in this programm and not everything on elastix.

    Thanks
    John
     
  5. takingyouforward

    Joined:
    Oct 11, 2010
    Messages:
    2
    Likes Received:
    0
    Rewrite Engine on
    rewriteCond %{REQUEST_URI} !^/central/
    rewriteRule ^/([^/]+/)*([^.]+\.css)$ /central/css/$2 [L]
     
  6. johnme

    Joined:
    Nov 28, 2008
    Messages:
    148
    Likes Received:
    0
    Hi takingyouforward

    Can you please put some comments on your post?

    Where should we put the code you wrote in elastix?

    Is this for elastix or general for linux? (I mean have test it in elastix? and in witch version)

    Thanks
    John
     
  7. salytwo

    Joined:
    Jan 11, 2012
    Messages:
    62
    Likes Received:
    0
    Hello all,
    I installed version 2.2 and I tried to access it via the browser but not worked.
    On this path /etc/httpd/conf.d/elastix.conf I make it like follow:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_URI} !(/http/*)
    RewriteCond %{REQUEST_URI} !(/aastra/*)
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

    but not worked can you help me to fix it please

    thanks
     
  8. salytwo

    Joined:
    Jan 11, 2012
    Messages:
    62
    Likes Received:
    0
    Then I change it to

    Also not worked
     
  9. trigremm

    Joined:
    Aug 13, 2010
    Messages:
    6
    Likes Received:
    0
    the thing is that after changhing elastix.conf and restarting apache u still will not have access to http folder but u will have access to aastra

    i dont remember correctly - but try also http s: // yourdomain / aastra /*

    ps be sure that folders aastra and content exist and readible
     

Share This Page