htaccess not working for port 443 ssl - .htaccess

I have configured ssl on port 443 for my site.. I have the same site on port 80 without http .. The problem is htaccess works fine on port 80 (without ssl) but doesn't work for https (port 443)
Here is my apache2 config
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster#localhost
DocumentRoot /home/SiteDir/
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /home/SiteDir/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /home/SiteDir/mobile/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
#other SSL Code
</VirtualHost>
</IfModule>

Related

How is it possible to run 2 Websites in 2 different subfolders on one Apache instance?

i just want to run 2 web applications which both are in seperate subfolders.
So Subfolder One (which is the Homepage) should be reachable under : example.com.
While Subfolder two should be reachable under example.com/subfolder .
I know it is somehow possible with the Apache vhosts file, but i am new to this vhost stuff und dont know, how to solve that problem.
Thanks for your help!
i just got it running like that! Is there any reason this could be a problem in sight of security?
<VirtualHost *:80>
ServerName example.com
ServerAdmin example#mail.com
Redirect permanent / https://example.com
DocumentRoot /var/www/webpage/
<Directory /var/www/webpage/>
</Directory>
</VirtualHost>
**And for SSL**
<VirtualHost *:443>
ServerAdmin example#mail.com
ServerName example.com:443
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>
DocumentRoot /var/www/webpage/
<Directory /var/www/webpage/>
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/webpage>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Alias /subfolder /var/www/subfolder/
<Directory /var/www/subfolder>
Order allow,deny
allow from all
</Directory>
SSLCertificateFile /etc/certs/live/**********/fullchain.pem
SSLCertificateKeyFile /etc/certs/live/**********/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

Htaccess doesn't work on MAMP with multiple sites

I have 3 sites on MAMP local server but in 2 of 3, the htaccess doesnt work.
I add this code in httpd.conf (MAMP->apache):
NameVirtualHost *
<VirtualHost *>
DocumentRoot "c:/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\codes\Bedloop"
ServerName local.bed.com
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\codes\apart"
ServerName local.apart.com
</VirtualHost>
And this lines on windows hosts file:
127.0.0.1 local.bed.com
127.0.0.1 local.apart.com
I put on 3 pages, the same files (same page), but htacces only work on the localhost page, not in other 2. The main page work fine, but urls with rewrite rules fails.
I need to config something more?
Thx!
NameVirtualHost is deprecated. Can you try these directives in your Apache vhost file and restart apache:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "c:\MAMP\htdocs"
<Directory "c:\MAMP\htdocs">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName local.bed.com
DocumentRoot "C:\codes\Bedloop"
<Directory "C:\codes\Bedloop">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName local.apart.com
DocumentRoot "C:\codes\apart"
<Directory "C:\codes\apart">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
</Directory>
</VirtualHost>

Nodejs can't establish a connection to the server at ws:// apache proxy

I am trying to configure my nodejs application to run on localhost with a domain name.
So my website on local is http://app.local which points to http://localhost/app
Now I have an app on nodejs which runs on 6060 port http://localhost:6060
I am trying to configure localhost:6060 to work on http://app.local/nodejs
Here's my apache config file.
<VirtualHost app.local>
ServerAdmin webmaster#app.local
ServerName app.local
ServerAlias app.local
DocumentRoot /var/www/app
ProxyPass /service http://localhost:3000
ProxyPassReverse /service/ http://localhost:3000/
ProxyPass /nodejs http://localhost:6060
ProxyPassReverse /nodejs/ http://localhost:6060/
ProxyPass /nodejs ws://localhost:6060
ProxyPassReverse /nodejs/ ws://localhost:6060/
<Directory >
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/app>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
My javascript code listen emits:
var socket = io.connect('http://app.local/', {path:'/nodejs/socket.io/', port: 6060});
socket.on('connect', function(){
console.log("Connected");
});
When I try to run the app through this URL http://app.local/nodejs, it throws following error:
Firefox can't establish a connection to the server at ws://app.local/nodejs/socket.io/?EIO=3&transport=websocket&sid=NQ2LSn--THwZkrStAAAH.
I followed this question but still not working.
I am using Apache/2.4.7 (Ubuntu)
Try the following:
Change
var socket = io.connect('http://app.local/', {path:'/nodejs/socket.io/', port: 6060});
to
var socket = io.connect('http://app.local:6060');

mod_rewrite not reading htaccess

I'm trying to enable mod_rewrite on server. My web is located in folder /data/web/new-domovreality.sk/web. There are .htacces and index.php files in this folder.
My current
etc/apache2/sites-available/default
<VirtualHost *:80>
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /data/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
I've read I think every instructions to enable it, but I'm not able to. Can someonehelp me? I'm doing this first time. Thanks
When I use phpinfo() there is mod_rewrite enabled.
So, the solution was to change the * to IP address, so in final
<VirtualHost *:80>
looks like this:
<VirtualHost 37.9.170.195:80>

Enable htaccess error on Ubuntu 12.04 with Apache2

I tried to enable htaccess. I changed:
<Directory /var/www/abc.biz/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
To:
<Directory /var/www/abc.biz/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
But I'm getting 500 (Internal Server) error. Why?
Here is my /etc/apache2/sites-available/default file:
<VirtualHost *:80>
ServerAdmin admin#abc.biz
DocumentRoot /var/www/abc.biz
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/abc.biz/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I think you need to change this part of your /etc/apache2/sites-available/default
DocumentRoot /var/www/abc.biz
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/abc.biz/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
to
DocumentRoot /var/www/abc.biz
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/abc.biz/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Because at first <Directory /> AllowOverride All you allow to override settings with your .htaccess file for the whole apache, but also you need to change it at <Directory /var/www/abc.biz/> AllowOverride All for your specific host directory, where your web site is placed.
Also you should check .htaccess files placed in your /var/www/abc.biz directory to be correctly writen, because when you enable .htaccess files to override global apache settings wrong .htaccess file causes such error.

Resources