I have a website example.com served by Apache, and example2.com redirected to port 3001 (using NodeJS). It works with this config:
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /home/www/example
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.example2.com
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:3001/$1 [P,L]
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/
</VirtualHost>
Now I would like to have this (because I won't renew the domain example2.com):
example.com => served by Apache => /home/www/example
example.com/website2 => redirected to the NodeJS website using 3001 (the one previously served on example2.com)
Question: I'm about to use the following code, but is it a correct use of Directory?
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /home/www/example
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
Require all granted
</Directory>
<Directory /website2/>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:3001/$1 [P,L]
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/
</Directory>
</VirtualHost>
I think you should use the <Location> directives for section based URL for stable operation.
Each section directives have priorities by order and section based. (section applied order)
<Directory> is based physical file system and low priority if the same section layered by multiple directives, such as <Location>, <Directory>, <File> and so on.
For example,
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /home/www/example
<Directory /home/www/example>
Options FollowSymLinks
AllowOverride All
#Order deny,allow
#Allow from all
# above access control conf mean same with below conf
Require all granted
</Directory>
# Location is not necessary to mod_rewrite directives.
# rewrite conf can be coontrol the conditions with RewriteCond
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/website2/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule ^/website2/(.*) ws://localhost:3001/$1 [P,L]
# ProxyPass is now allowed into Location as following patterns,
# but 'ProxyPass http://localhost:3001/' is available into the Location directive but limited in Location URL pattern.
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/
</VirtualHost>
Related
I have a Vuejs App deployed at apache2 server in digitalocean , when you hit the url it forwards you to login page which is working fine and then automatic navigate me to dashboard page that have cards when I click on one of cards I get 404 page even after I edit my .htaccess file in dist
NOTE the card route is domain.com/build
I tried .htaccess configuration from docs
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
and here is my virtual host configuration
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin email
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain.com/public_html/app/dist
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPass /api/ http://localhost:8000/
ProxyPassReverse /api/ http://localhost:8000/
RewriteEngine on
# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.
#RewriteCond %{SERVER_NAME} =domain.com
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
Nothing wrong with virtual host file, the problem was in apache2.conf file in /etc/apache2. what I need is to change this part from
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
to :
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
you need to change the AllowOverride attribute.
I am having two domains example xyz.xx and pqrs.net and pointing to same IP.
xyz.xx apache htaccess configuration was done long back and running perfectly fine with this config
Listen : 80
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin testacc#gmail.com
DocumentRoot /www/docs/xyz.xx
ServerName xyz.xx
ServerAlias www.jxyz.xx
<Directory "/www/docs/xyz.xx">
AllowOverride None
Options All
Order allow,deny
Allow from all
DirectoryIndex index.php index.html index.htm
</Directory>
JkMount /test/*.jsp router
JkMount /test/*.html router
</VirtualHost>
Now I am trying to configure htaccess for pqrs.net but facing difficulties , Not sure why it is happening.Need Help.
Here is my other part of htaccess configuration added for pqrs.net:
Listen : 8081
NameVirtualHost XXX.XX.XX.XX:8081
<VirtualHost XXX.XX.XX.XX:8081>
ServerAdmin hello#gmail.com
DocumentRoot /www/docs/pqrs.net
ServerName pqrs.net
ServerAlias www.pqrs.net
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_REFERER} !^$
RewriteRule ^/$ /xxx/usa/index.html [L,PT]
RewriteCond %{REQUEST_URI} !^/xxx/.*
RewriteCond %{REQUEST_URI} !^.*\.do.*
RewriteRule ^/(.*) /xxx/$1 [L,PT]
JkMount /property/*.jsp xxxrouter
JkMount /property/*.html xxxrouter
<Directory "/www/docs/">
AllowOverride None
Options All
Order allow,deny
Allow from all
DirectoryIndex index.html
</Directory>
</VirtualHost>
and here is my workers.properties
worker.list=router
worker.list=xxxrouter
worker.xxxrouter.port=8011
worker.xxxrouter.host=localhost
worker.xxxrouter.type=ajp13
worker.xxxrouter.reply_timeout=100000
worker.router.port=8009
worker.router.host=localhost
worker.router.type=ajp13
worker.router.reply_timeout=100000
Please help me on this , when i am trying to access pqrs.net , it shows me this error message on browser.
The requested URL /xxx/usa/index.html was not found on this server.
I am using this code in httpd.conf
<VirtualHost *:4080>
# This will enable the Rewrite capabilities
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
ServerAdmin serveradmin
DocumentRoot "/etc/zpanel/panel/"
ServerName panel.mydomain.com
ServerAlias *.panel.mydomain.com
AddType application/x-httpd-php .php
<Directory "/etc/zpanel/panel/">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I need http://domain.com:4080 to redirect to secure ://domain.com:4080, which is happening but certificate is not working
If I remove the auto redirection code
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) [https://%{HTTP_HOST}%{REQUEST_URI}][1]
and goto secure: //domain.com:4080 in browser myself certificate shows up.
I need something like cpanels auto redirection to https
Try http://ziing.net:2087/
i have specific rewrite like
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule .* /app_dev.php
and i need domain names like hello.epsilon.localhost and example.epsilon.localhost will go to epsilon.localhost virtualhost (sorry for my bad english)
full virtualhost for epsilon.localhost
<VirtualHost *:80>
DocumentRoot "C:/Projects/epsilon/web"
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule .* /app_dev.php
<Directory "C:/Projects/epsilon/web">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ServerName epsilon.localhost
</VirtualHost>
this rewrite for symfony 2.1
I'm using this http://sourceforge.net/projects/acrylic/ as a local DNS server on windows
and this in the Virtual host configuration
<VirtualHost 127.0.0.1>
ServerName devsite.localhost
ServerAlias *.devsite.localhost
DocumentRoot "C:/httpdocs/devsite"
</VirtualHost>
Can someone tell me why I can't view my index.php from the subdir /oorbellenboutique/?
It shows http:// www.oorbellenboutique.nl/startpagina/index.php, but it must be the index.php from f:/inetpub/wwwroot/oorbellenboutique
The correct URL is: http:// www.oorbellenboutique.nl/index.php
My DNS is:
A *.oorbellenboutique.nl → 83.87.163.224
A oorbellenboutique.nl → 83.87.163.224
CNAME www.oorbellenboutique.nl → oorbellenboutique.nl
My URL is: http://www.oorbellenboutique.nl
I'm running Apache 2.x
NameVirtualHost 192.168.0.199:80
NameVirtualHost 192.168.0.199:443
<VirtualHost 192.168.0.199:80 192.168.0.199:443>
ServerName oorbellenboutique.nl
ServerAlias www.oorbellenboutique.nl
DocumentRoot f:/inetpub/wwwroot/oorbellenboutique
RewriteEngine On
KeepAlive Off
DocumentRoot "f:/inetpub/wwwroot"
<Directory f:/inetpub/wwwroot/oorbellenboutique>
DirectoryIndex index.php
Order deny,allow
Allow from all
</Directory>
RewriteCond %{HTTP_HOST} ^(?:www\.)?oorbellenboutique\.nl$
ReWriteRule ^(.*) /oorbellenboutique/$1
</virtualhost>
This works but the URL is now:
http:// www.oorbellenboutique.nl/oorbellenboutique/index.php
How can I make the URL shorter like:
http:// www.oorbellenboutique.nl/index.php
NameVirtualHost 192.168.0.199:80
NameVirtualHost 192.168.0.199:443
< VirtualHost 192.168.0.199:80 192.168.0.199:443>
ServerName www.oorbellenboutique.nl
ServerAlias *.oorbellenboutique.nl oorbellenboutique.nl
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www.)?oorbellenboutique.nl$
<Directory f:/inetpub/wwwroot/oorbellenboutique>
DirectoryIndex index.html index.php
Order deny,allow
Allow from all
</Directory>
RewriteRule ^/$ /oorbellenboutique/ [R]
< /virtualhost>
Try adding a RewriteBase directive immediately following the RewriteEngine directive:
RewriteBase f:/inetpub/wwwroot
That is not the same as DocumentRoot for functionality -- it is needed for mod_rewrite.