How to access web page using ip for laravel? - php

I am having problem to access my website using ip from a different pc. For example, the ip that I want to access is 192.168.0.150/season_pass. If I use that ip, the page could not be found but if I just enter 192.168.0.150, it can access the web page. Supposedly 192.168.0.150 should redirect to the dashboard page.
Below are the https-vhosts.conf file that I edit,
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\season_pass\public"
ServerAdmin admin#localhost
ServerName season_pass
<Directory "C:\xampp\htdocs\season_pass\public">
AllowOverride All
Options Indexes FollowSymLinks
Require local
Require all granted
</Directory>
</VirtualHost>
The hosts file,
127.0.0.1 season_pass
::1 season_pass
For the apache, I am using xampp and the development is on laravel framework.

Related

How to access virtual host from the internet?

I want to access my website via virtual host from the internet. For now, I am using the public IP address of my server to access my website. Here is what I am using (please see below).
http://122.4.195.12:7777/site/index.php
Is there a way to access my virtual host from the internet? When I am accessing my virtual host from my internet (https://mysite/site/index.php) I am getting
DNS_PROBE_FINISHED_NXDOMAIN error
mysite’s server IP address could not be found.
Is there a way to add a SSL when accessing my website via public IP address? When I change http into https I am getting
ERR_SSL_PROTOCOL_ERROR
122.4.195.12 sent an invalid response.
http://122.4.195.12:7777/site/index.php -> https://122.4.195.12:7777/site/index.php
Here is my Virtual Host Config:
<VirtualHost *:7777>
DocumentRoot "C:\xampp\htdocs"
ServerName mysite
<Directory "C:\xampp\htdocs">
Require all granted
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "C:/xampp/htdocs"
ServerName mysite
SSLEngine on
SSLCertificateFile "crt/scratchitsite/server.crt"
SSLCertificateKeyFile "crt/mysite/server.key"
<Directory "C:\xampp\htdocs">
Require all granted
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Here is the host file of my server:
127.0.0.1 mysite
For question 1
The easier way will still be registering a domain name, point it to your IP address, and setup your VirtualHost ServerName for it
The VirtualHost actually detecting the Host HTTP Header from server site, so the key thing here is:
How to make the client browser send the Host header the same with you defined on server
For example, by using CURL you can force it to use the user definied Host header like this: curl -H 'Host: mysite' 122.4.195.12:7777/site/index.php
If you're using Chrome, you can try to use a browser extension, like this
For question 2
You've enabled HTTPS on port 443 instead of 7777 in your Apache configuration
Which means you should access your HTTPS service like this https://122.4.195.12:443/site/index.php instead of this https://122.4.195.12:7777/site/index.php

How to access XAMPP virtual host from another computer or device?

I want to access my virtual host using my phone or my other computer the problem is I cannot access my site using the server name I can only access the site using the IP address of the server. I changed the port to 7777
When I tried www.tbs.com:7777/index.php I am getting "site cannot be reached"
Virtual Host Config:
<VirtualHost *:7777>
DocumentRoot "c:/xampp/htdocs/TBSApp"
ServerName www.tbs.com
ServerAlias tbs.com
ServerAdmin webmaster#localhost
<Directory "c:/xampp/htdocs/TBSApp">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
order allow,deny
allow from all
</Directory>
</VirtualHost>
Host Config
192.168.120.9 www.tbs.com
You need to use the ip address instead of the domain as it is a local host configuration. To use the domain across all devices you need to setup a DNS server.

Site not loading, apache configuration

ATTN! I should mention this is all localhost. As in my machine, no servers or other jazz included.
I am really bad at configuring sites in apache, how ever I have the following config:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/image_upload_app
ServerAlias www.dev-imageuploadapp.com
<Directory /var/www/html/image_upload_app>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
And when ever I visit www.dev-imageuploadapp.com, I get a "The web page is not available" in chrome.
There are no errors in the access or the error log, after attempting to visit the page. Apache is running and the site is enabled.
The directory does exist and contains a index.php.
You need to set ip address of your site on DNS Servers. There is some free DNS Servers like https://www.cloudflare.com/. If you do in this way, you need to set delegated DNS Servers on your domain-holder site. Another try you can go to site to IP by http://{your-ip-address}/
Your browser needs to know which IP address is to use for a provided name. To enforce some values to localhost, you can add them into hosts file. Following line needs to be added:
127.0.0.1 www.dev-imageuploadapp.com
In /etc/hosts change the line:
127.0.0.1 localhost
To
127.0.0.1 localhost www.dev-imageuploadapp.com

Can't access laravel page in vhost setup

I have a problem with the set up of laravel using a vhost. I have a different projects using vhost and it has no problem but when I try to set up this with Laravel I can't access it in my web browser. It just redirect to google page and searching for my vhost url.
So far here's what I did.
I included my vhost entry in httpd-vhosts.conf file
<VirtualHost *:80>
ServerName dev.laravel_validation.local
ServerAlias dev.laravel_validation.local
DocumentRoot "C:/Users/Web4/Desktop/laravel/laravel_validation/public"
<Directory "C:/Users/Web4/Desktop/laravel/laravel_validation/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
I include the name in Windows hosts file
127.0.0.1 dev.laravel_validation.local
Then restart Wampserver. And I access the URL dev.laravel_validation.local to my browser but it doesn't display the Laravel's welcome page.
I don't know where did I go wrong. Can you help me with this?

WAMP httpd.config redirect

I'm using wamp on localhost at c:\wamp\www\.
The project located under: c:\wamp\www\MyProj\public (root).
In file1.php (located in root) I have a link to some fake url (/services/.....).
I'm trying to redirect that url to other file service_router.php (in the same direction as file1.php).
I'm doing that in httpd.config:
<VirtualHost *:80>
ServerName 127.0.0.1
DocumentRoot c:\wamp\www\
<Directory "c:\wamp\www\">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/MyProj/public/services/*
RewriteRule . /MyProj/public/service_router.php
</VirtualHost>
But my WAMP refuses to restart.
What's wrong with my configurations?
Can I make a few suggestions.
If you want to use Virtual Hosts, and I consider that a very good idea. You need first to make sure that localhost still works and secondly it is a good idea to move you actual projects out of the \wamp\ folder structure.
So this would be a good starting point for your first ( of many ) VHOSTS
First create a new folder structure somewhere on any of your drives for example
C:\websites\project1\www
Now copy your project to the www folder.
Now setup the vhosts
# must be first VHOST so the that localhost and the wamp menu page still work
# Also makes this the default site so any randon hacks on your ip address
# will come here and hopefully be rejected because it only 'Allows' access
# from this machine ( see Allow Deny )
<VirtualHost *:80>
DocumentRoot "D:/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>
DocumentRoot "C:/websites/project1/www"
ServerName project1.dev
ServerAlias www.dqsc.old
Options Indexes FollowSymLinks Includes ExecCGI
<Directory "C:/websites/project1/www">
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Unless you actually want to make this site available to the World can I suggest that you dont use Allow from all.
Try using or the second Allow line if you want to see your site from any machine on your internal network, just use the first 3 of the 4 quartiles of your ip address and it will allow access from any ip starting with those 3 quartiles.
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
Allow from 192.168.0
Now you need to amend your HOSTS file so that windows knows about your new domain name.
Edit c:\windows\system32\drivers\etc\hosts and add the new site name project1.dev like so, you will have to launch your editor 'Run as Administrator' as this file is protected by windows :-
127.0.0.1 project1.dev
Now restart the "DNS Client" service to refresh the windows dns cache so it see's your new domain name. Start a command window, again "Run as Administrator".
net stop "DNS Client"
net start "DNS Client"
You should now be able to enter http://project1.dev in a browser and it will find you new site.
Finally, once you test that your site is working, put the url rewrite coding in a .htaccess file in the root of your new project.
C:\websites\www\project1\.htaccess

Categories