I have installed wamp64. configured various vhosts which work well except for one address which the system forces to go to HTTPS instead of HTTP like the rest of them. dev.test.com is forced to go to HTTPS://dev.test.com instead of HTTP://dev.test.com and of course the file is not found.
dev.test2.com goes to HTTP,
example goes to HTTP
I had a XAMPP install that had a vhosts file which had a redirect for dev.test.com to HTTPS. Thinking this might somehow interfere, I renamed that XAMPP vhost file, but I still get the same problem even after a computer reboot.
In wamp64 I am able to create any other vhost and have it work fine, but not this one. What could be causing this?
wamp64, version 3.2.9, php 7.4, apache 2.4.51
WAMP VHOST FILE:
<VirtualHost *:80>
ServerName example
DocumentRoot "c:/wamp64/www/example"
<Directory "c:/wamp64/www/example/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#
<VirtualHost *:80>
ServerName dev.test.com
DocumentRoot "c:/wamp64/www/dev.test.com"
<Directory "c:/wamp64/www/dev.test.com/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#
<VirtualHost *:80>
ServerName dev.test2.com
DocumentRoot "c:/wamp64/www/dev.test2.com"
<Directory "c:/wamp64/www/dev.test2.com/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#
My previous XAMPP VHOST FILE - NOW RENAMED TO DISABLE IT (httpd-vhosts_old.conf)
<VirtualHost dev.test.com:80>
ServerName dev.test.com
DocumentRoot "C:\xampp\htdocs\dev.test.com"
<Directory "C:\xampp\htdocs\dev.test.com">
Options All
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/dev.test.com-error.log"
CustomLog "dev.test.com-access.log" combined
#redirect non SSL URI to SSL URI
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.dev.test.com [OR]
RewriteCond %{SERVER_NAME} =dev.test.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
I ended up configuring a local SSL certificate for the server and converted all local hostnames to access SSL which worked fine. I know this does not answer the posted question, but at least allowed me to proceed.
Related
I have to migrate an Apache configuration file to Nginx but as I have no experience in Nginx I would like some help.
This is my apache setup:
000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
<Directory /var/www/ff>
AllowOverride All
Options -Indexes
</Directory>
DocumentRoot /var/www
RedirectMatch ^/$ /ff/
Alias "/uploads" "/var/www/ff/uploads/"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I’m a little lost as using the parameter RedirectMatch in nginx, I guess it has another name
help me create a configuration file for nginx?
Regards,
Hi I'm hardening a WordPress site that uses Apache for the web server. I want to block access from servername.admin.company.com. I tried editing HTACCESS per another answer I saw here, but the site started 500'ing from https://domainname.com. There are a ton of security issues, and we decided the best way to handle it is to just block access completely since no one really needs to access it that way.
Here's my vhosts file:
' <Directory "/var/www/directory">
AllowOverride All
Options -Indexes +FollowSymLinks
Require all granted
Require not host servername.admin.company.com
</Directory>
DirectoryIndex index.php index.html
<VirtualHost *:80>
ServerName site.com
ServerAlias www.site.com
DocumentRoot "/var/www/directory"
# Enable HSTS (tell browsers to use only HTTP)
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload;"
<Directory "/var/www/html">
AllowOverride All
Options -Indexes +FollowSymLinks
Require all granted
</Directory>
RewriteEngine on
RewriteRule "^(.*/)?\.git/" - [F,L]
RedirectMatch 404 /\.git
</VirtualHost>
<VirtualHost *:80>
ServerName business.site.com
ServerAlias subdomain.site.com
ServerAlias www.business.site.com
DocumentRoot "/var/www/directory"
# Enable HSTS (tell browsers to use only HTTP)
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload;"
<Directory "/var/www/site">
AllowOverride All
Options -Indexes +FollowSymLinks
Require all granted
</Directory>
RewriteEngine on
RewriteRule "^(.*/)?\.git/" - [F,L]
RedirectMatch 404 /\.git
CustomLog /var/log/httpd/site-requests.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName business.site.com
ServerAlias directory.site.com
ServerAlias www.subfolder.site.com
DocumentRoot "/var/www/sitefolder"
# Enable HSTS (tell browsers to use only HTTP)
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload;"
<Directory "/var/www/sitefolder">
AllowOverride All
Options -Indexes +FollowSymLinks
Require all granted
</Directory>
RewriteEngine on
RewriteRule "^(.*/)?\.git/" - [F,L]
RedirectMatch 404 /\.git
CustomLog /var/log/httpd/sitefolder-requests.log combined
ErrorLog /var/log/httpd/sitefolder-error.log
</VirtualHost>
'
You can achieve this in various ways, iptables, .htaccess, etc.
Please visit this URL, what you need to do is well documented there:
https://httpd.apache.org/docs/2.4/en/howto/access.html
I hope it helps you.
I'm using apache 2.2.15, in a virtual machine over CentOS 6, I have a symfony proyect working here and my boss want to load a wordpress website in the same server on a subdomain.
Subdomain is not working, I've tried a lot of configurations, this is the last one used:
mysite.cl.conf (in /etc/httpd/conf.d folder)
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html/symfonyProyect/web
ServerName mysite.cl
ServerAlias mysite.cl
ErrorLog /var/log/httpd/symfonyProyect_error.log
CustomLog /var/log/httpd/symfonyProyect_access.log combined
<Location />
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /app.php [L]
</IfModule>
DirectoryIndex app.php
</Location>
</VirtualHost>
<VirtualHost *:80>
ServerName mysubdomain.mysite.cl
DocumentRoot /var/www/html/mysubdomain
<Directory /var/www/html/mysubdomain>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/mysubdomain_error.log
CustomLog /var/log/httpd/mysubdomain_access.log combined
</VirtualHost>
my hosts file (in /etc folder)
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
myip mysite.cl mysubdomain.mysite.cl
and my hosts.conf
multi on
when I try mysite.cl it shows the symfony website, but when I try mysubdomain.mysite.cl, it gives me the "This site can't be reached" or "ERR_NAME_NOT_RESOLVED".
The if I delete the first VirtualHost block, it showsme the wordpress website ( even using ServerName mysubdomain.mysite.cl).
Am I missing some configuration or something??
The error you are getting is a DNS one not one from Apache. You need to modify the hosts file on same machine you are trying to browse to mysubdomain.mysite.cl.
Open a command prompt/shell on the machine you are running your browser on and just run ping mysubdomain.mysite.cl if it works your browsing should work too. If you get a message something like ping: unknown host mysubdomain.mysite.cl (Linux) or Ping request could not find host mysubdomain.mysite.cl (Windows). then simply edit the hosts file on that system or get a DNS entry added to your name server.
Simply editing /etc/hosts on the server that Apache runs on doesn't cause all other hosts to be able to resolve a hostname to an IP address.
I have a wordpress site running on wordpress.myorg.com. For authentication I have to redirect it my internal server running CAS server.
Internal Server does not have DNS name. So, I’m using local DNS with IP address in HOST file to redirect to CAS server. All the things working correctly such a way.
Now I wanted to add ProxyPass rules, so that the User only sees wordpress.myorg.com all the time.
After adding ProxyPass rules, when I hit wordpress.myorg.com/wp-login.php it returns page with 500 internal error rather then showing CAS login screen.
Here is the Virtual Host entry I have done in Apache web server for Wordpress Site
<VirtualHost *:80>
ServerAdmin your_email_address
ServerName wordpress.myorg.com
ServerAlias wordpress.myorg.com
DocumentRoot /var/www/html/wordpress
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/wordpress>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTPS} !=on
RewriteRule ^/?CAS/(.*) https://wordpress.myorg.com/CAS/$1 [R,NE,L]
</VirtualHost>
<VirtualHost *:443>
ServerAdmin your_email_address
ServerName wordpress.myorg.com
ServerAlias wordpress.myorg.com
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/myorg.com.crt
SSLCertificateKeyFile /etc/apache2/ssl/myorg.com.key
ProxyRequests On
ProxyVia On
ProxyPass /CAS/ ajp://cas.myorg.com:8009/CAS/
ProxyPassReverse /CAS/ ajp://cas.myorg.com:8009/CAS/
</VirtualHost>
Any help on this would be appreciable.
Thanks.
Got the issue. I forgot to enable SSLProxyEngine. Just enabled it and its working like a charm.
Edit for HTTPs portion.
<VirtualHost *:443>
ServerAdmin your_email_address
ServerName wordpress.myorg.com
ServerAlias wordpress.myorg.com
SSLEngine on
## Added these lines ##
SSLProxyEngine On
SSLProxyCheckPeerCN on
SSLProxyCheckPeerExpire on
## -- ##
SSLCertificateFile /etc/apache2/ssl/myorg.com.crt
SSLCertificateKeyFile /etc/apache2/ssl/myorg.com.key
ProxyRequests On
ProxyVia On
ProxyPass /CAS/ ajp://cas.myorg.com:8009/CAS/
ProxyPassReverse /CAS/ ajp://cas.myorg.com:8009/CAS/
</VirtualHost>
I have a problem here with Symfony 2. I want to have virtual host on Windows Vista PC, so I can access my Symfony application like this myapp.local.com.
What I have tried:
I added these lines to hosts file
127.0.0.1 local.com
127.0.0.1 myapp.local.com
These I added to apache httpd-vhosts.conf
< VirtualHost myapp.local.com:80 >
DocumentRoot "d:/data/www/myapp/web"
ServerName myapp.local.com
Alias /sf /$sf_symfony_data_dir/web/sf
< Directory "/$sf_symfony_data_dir/web/sf" >
AllowOverride All
Allow from All
< /Directory >
< Directory "d:/data/www/myapp/web" >
AllowOverride All
Allow from All
< /Directory >
< /VirtualHost >
but when I write myapp.local.com in my browser, it brings the index of my www directory. What am I doing wrong?
You are using the virtualhost configuration proposed for Symfony 1.
My virtualhost for Symfony2 under linux looks like this:
<VirtualHost *:80>
ServerName www.domain.com.localhost
ServerAlias domain.com.localhost
ServerAdmin webmaster#localhost
DocumentRoot /home/user/www/project/web
<Directory /home/user/www/project/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.php [QSA,L]
</IfModule>
</Directory>
</VirtualHost>
Try this (adapted to your config in windows), restart Apache, and try accessing the URL again.
You will find more informations on Symfony2 virtual hosts on this cookbook entry.
Windows version for symfony 3.4:
Just simple like this:
C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/symfony_CRUD/web"
DirectoryIndex app_dev.php
ServerName fudu.symfony.net
</VirtualHost>
C:\Windows\System32\drivers\etc
127.0.0.1 fudu.symfony.net
Then you go fudu.symfony.net/app_dev.php
Hope it help some one :)