VirtualHost with default IP address - wamp

i create new VirtualHost
<VirtualHost lar.local>
DocumentRoot "C:\\wamp\\www\\laravel\\public\\"
ServerName lar.local
ServerAlias lar.local
<Directory "C:\\wamp\\www\\laravel\\public\\">
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
My host file:
127.0.0.1 localhost
127.0.0.1 lar.local
When i open - lar.local works fine.
But when i open default WAMP address (127.0.0.1), i get "C:\wamp\www\laravel\public\" also the same directory. Why?
Why with 127.0.0.1 i can't open root server directory (C:\wamp\www\) as before?
How fix this

Related

wamp server: website is online but isn't responding to connection attempts

when attempting to connect through public IP it gives the above error. sometimes in the error log, it says blocked by configs. however, it still shows up in the access log. this is the vhosts file:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "C:/wamp64/www"
<Directory "C:/wamp64/www/">
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I tried a number of things such as restating and using different devices.
edit: I get the same error even if the server is offline.

How to redirect google VM external ip address to HTTPS in django with Debial and Apache?

I have successfully installed SSL certificate with certbot and lets encrypt on my debian and apache linux virtual machine on google cloud.
the domain is successfully secure with HTTPS.
Although on directly accessing the external ip address i am still getting an unsecure version of the website.
How to redirect the ip directly to the HTTPS version set up with APACHE and just the "domain.com" towards -->> HTTPs:www.domain.com .
I have tried to re-route to port 80 and 443 towards the HTTPS version as in PHP without any luck as shown here :
How to redirect from www to https www with htacces?
in my 000-default.conf:
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster#localhost
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.bracketline.com [OR]
RewriteCond %{SERVER_NAME} =localhost
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI}
[END,NE,R=permanent]
</VirtualHost>
and on my 000-default-le-ssl.conf i have:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName localhost
ServerAdmin webmaster#localhost
Alias /static /var/www/static-root
<Directory /var/www/static-root>
Require all granted
</Directory>
Alias /media /var/www/media-root
<Directory /var/www/media-root>
Require all granted
</Directory>
<Directory /var/www/venv/src/cfehome>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess cfehome python-
path=/var/www/venv/src/:/var/www/venv/lib/python3.5/site-packages
WSGIProcessGroup cfehome
WSGIScriptAlias / /var/www/venv/src/cfehome/wsgi.py
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerAlias www.bracketline.com
SSLCertificateFile
/etc/letsencrypt/live/www.bracketline.com/fullchain.pem
SSLCertificateKeyFile
/etc/letsencrypt/live/www.bracketline.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
I am not sure how this thing works if a detailed blog or turorial could be given it would be of great help. thanx in advance!
First lacate which .conf file youre actually using by typing apachectl -S (this works on Debian based OS'es).
Next up edit the file, it should look simillar:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
Redirect permanent / https://example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
Protocols h2 http/1.1
# SSL Configuration
# Other Apache Configuration
</VirtualHost>
In general there are several tutorials how to configure HTTP to HTTPS redirect:
Redirect HTTP to HTTPS in Apache
How to Redirect HTTP to HTTPS on Apache
Apache Redirect to HTTPS
And some interesting discusson Why is my Apache VirtualHost directing to the wrong VirtualHost?
Lastly - here's another SO discussion on that topic that has an accepted answer.
Those are just recent (up to 2 years old) examples that will help you and there are dozens more if they won't answer your questions.

HTTP to HTTPS redirect Vagrant

So I've been having an issue with Vagrant and Port Forwarding...
Currently, Vagrant is already forwarding ports 80 -> 8080 and 443 -> 8443. Issue is, I don't want a client to have to type ports 8443 and 8080 to access my web page. So now, the client has to type in 127.0.0.1:8080 or 127.0.0.1:8443 to access the webpages.
How would I go about changing this? My current stack is VM, Vagrant, Apache, Django.
I have 2 VHosts setup. Heres my sites-available/mysite.com file
<VirtualHost *:80>
ServerAdmin webmaster#example.com
#ServerName spritebots.com
#ServerAlias www.spritebots.com
ServerName 127.0.0.1
ServerAlias 127.0.0.1
ProxyRequests off
ProxyPreserveHost On
ProxyPass / https://127.0.0.1:8443
ProxyPassReverse / https://127.0.0.1:8443
#Redirect permanent / https://127.0.0.1:8443
</VirtualHost>
<VirtualHost *:443>
WSGIDaemonProcess spritebots
WSGIProcessGroup spritebots
WSGIScriptAlias / /var/www/spritebots/apps/wsgi.py
ServerAdmin webmaster#example.com
#ServerName spritebots.com
#ServerAlias www.spritebots.com
ServerName 127.0.0.1
ServerAlias 127.0.0.1
DocumentRoot /var/www/spritebots/
Alias /media/ /var/www/spritebots/static/media/
Alias /static/ /var/www/spritebots/static/
<Directory /var/www/spritebots/static>
Order deny,allow
Allow from all
</Directory>
<Directory /var/www/spritebots/static/media>
Order deny,allow
Allow from all
</Directory>
SSLEngine on
SSLCertificateFile /etc/ssl/certs/spritebots.crt
SSLCertificateKeyFile /etc/ssl/certs/spritebots.key
</VirtualHost>
So I bought a domain name, spritebots.com and I can't even get spritebots.com to point to 127.0.0.1:8443.
But for now, I would like for anyone visiting my site at 127.0.0.1, to be redirected 127.0.0.1:8443, then mask the port number. Basically like how every production web page is with HTTPS enabled.
Does a majority of developers/companies use vagrant or VMs for production web sites? Because I feel that Vagrant's port forwarding is messing this up. Or it's more possibly me just being ignorant of web development. :(
Any help would be greatly appreciated!
In your Vagrantfile, you can assign your VM a private network IP, by dropping in:
config.vm.network "private_network", ip: "192.168.50.5"
Then you don't have to mess with ports.

Aid in setting up a Virtual Host with Wamp in Windows Vista

I need some help in setting up this thing.
I followed a tutorial about setting up a virtual host in WAMP which included the following steps:
Opened file httpd.conf in folder C:\wamp\bin\apache\apache2.2.6\conf and uncommented the last # of the following statement:
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf"
to look like this:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Opened the file httpd-vhosts.conf in folder C:\wamp\bin\apache\apache2.2.6\conf\extra, deleted everything in there and replaced with these codes below:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.jagerseow.servegame.com (WHICH IS A DOMAIN A REGISTERED IN NO-IP)
ServerAlias jagerseow.servegame.com domain
DocumentRoot C:/wamp/www/MP4Public
ErrorLog "C:/wamp/www/MP4Public/logs/error.log"
CustomLog "C:/wamp/www/MP4Public/logs/access.log" common
</VirtualHost>"
<VirtualHost *:80>
ServerName localhost
DocumentRoot C:/wamp/www
ErrorLog "C:/wamp/www/logs/error.log"
CustomLog "C:/wamp/www/logs/access.log" common
</VirtualHost>
Used Notepad to open file hosts in folder C:/Windows/System32/drivers/etc on server computer; then, deleted and replaced the default codes with these codes:
127.0.0.1 localhost
127.0.0.1 domain
Restarted WAMP and waited until it turned green, which it did ...
Try to connect to my server page by typing domain in the browser and my web page showed up normally. However when anyone, including myself, tries to open it by typing the address (http://www.jagerseow.servegame.com), no page is loaded.
I'm running Windows Vista 32-bit. Anyone can tell me what I'm doing wrong?
Change your Virtual Hosts definition to this:-
NameVirtualHost *:80
## must be first so the the wamp menu page loads
## and stray hacks get sent here and ignored because access
## is only allowed from local ips (127.0.0.1 localhost ::1 )
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.jagerseow.servegame.com
ServerAlias jagerseow.servegame.com
DocumentRoot "C:/wamp/www/MP4Public"
# changed, dont want your logs available under your docroot directory (security)
ErrorLog "C:/wamp/www/logs/MP4Public_error.log"
CustomLog "C:/wamp/www/logs/MP4Public_access.log" common
<Directory "D:/wamp/www/MP4Public">
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>"
Now you need to change your hosts file to :-
127.0.0.1 localhost
127.0.0.1 jagerseow.servegame.com
After changing this do the following, or reboot.
Run a command window Run as Administrator and do
net stop "DNS Client"
net start "DNS Client"
This will force a refresh of the DNS Cache and make the new domain name available on your PC.
The hosts file is loaded by windows into its DNS cache. It pre-loads urls and is a bit like a very low function DNS. So this tell the dns cache and therefore your browser etc that jagerseow.servegame.com is found on ip address 127.0.0.1 which is this PC
If you actually did want the universe to be able to see this site, I assume you do as you used Allow from all, you will then have to port forward port 80 on your router to the ip address of the PC running wamp. Also that PC will need a STATIC ip address so it does not change when you reboot. Help for that can be found here PortForward.com

Virtual Host with WAMP

I'm using Wamp 2.2, edited conf/extra/httpd-vhosts.conf edited this file to add VirtualHosts , but when I un-commented line in httpd.conf to include httpd-vhosts.conf file, after restarting Wamp doesn't starts. If I revert changes is works fine.
Any ideas why is this happening?
This is code I'm using in httpd-vhost.conf:
<VirtualHost *>
ServerAdmin admin#localhost.com
DocumentRoot "C:/wamp/www" # change this line with your htdocs folder
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
# WooCommerce Multisite
<VirtualHost dev.lo>
ServerAdmin admin#localhost.com
DocumentRoot "C:/wamp/www/dev"
ServerName dev.lo
ServerAlias dev.lo
<Directory "C:/wamp/www/dev">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Thanks
George
Edit
As Andreas Hagen suggested, I run Apache via httpd.exe.
First error was wrong parameter for DocumentRoot, as appears comment like was taken as second parameter, when DocumentRoot accepts only one.
Then I got warning: [warn] NameVirtualHost *:80 has no VirtualHosts. Did a quick search and found very helpful question - https://serverfault.com/questions/1405/apache-2-startup-warning-namevirtualhost-80-has-no-virtualhosts
Probably some bad config in vhosts file. Try to start apache from commandline so you get the error output. That will help you identify your problem.
Open your hosts file (\WINDOWS\system32\drivers\etc\hosts).
Add this line to the bottom:
127.0.0.1 test
This will tell your computer that any url that contains test will be routed to 127.0.0.1 (localhost).
Now open httpd.conf and add this to the very bottom of the file:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/myfirstsite/"
ServerName testsite
</VirtualHost>
Now restart apache and navigate to: http://test/ (you may have to restart your browser for the changes to take effect.)
Hope this works.
Go to C:/drive and choose wamp folder
and go to C:\wamp\bin\apache\Apache2.4.4\conf and choose httpd.conf file.
Edit with notepad and go to 58 line number
change Listen 80 and replace Listen 8181 Save file and restart your Apache server
Now check url such like this localhost:8181
I have used this hop you will be success.