Laravel 5 - how to change route() and assets() url - laravel

When I use the following helpers:
assets('css/app.css');
route('home');
..it generates this URL: "http://myapp.vagrant/css/app.css"
However, I want to change the URL to generate "http://192.168.1.134:8088" as, in my case, a network IP is what I need.
I can find where "myapp.vagrant" is set though. I've change Homestead.yaml and .env files, I've destroyed then vagrant up again. I've tried grep to locate where else this domain might be defined.
Any suggestions? The URL http://192.168.1.134:8088 is pointing correctly to the site but the urls that are generated are using the wrong URL (myapp.vagrant)
Btw here's my apache config file (/etc/apache2/sites-available/myapp.conf):
<VirtualHost *:8088>
ServerName mydomain.com
ServerAlias www.mydomain.com
ProxyPass "/" "http://myapp.vagrant/"
ProxyPassReverse "/" "http://myapp.vagrant/"
</VirtualHost>
So http://192.168.1.134 is the host machine, and I want port 8088 to point to http://myapp.vagrant/ (/etc/hosts points this domain to the vagrant IP) .. unless Laravel is picking up this domain from here?

you can use .env file to set it
APP_URL=http://192.168.1.134:8088

Related

Alias in virtual host using xamp in Laravel 5.6 project

I created a virtual host in xampp for my Laravel 5.6 project.
I did this way:
I added 127.0.0.1 project.com in the hosts file in
C:\Windows\System32\drivers\etc
I changed the port 80 to 8003 in the httpd.conf file in C:\xampp\apache\conf (I changed everything from 80 to 8003 in this file)
I added this:
<VirtualHost *:8003>
DocumentRoot "C:/xampp/htdocs/project/public"
ServerName project.com
</VirtualHost>
in the httpd-vhosts.conf in C:\xampp\apache\conf\extra
I would like to use an alias because I do not want to use the url with the number port at the of the url. I just can access with this url: http://project.com:8003.
I want to enter to my project with the url like this: http://project.com
If you don't want to specify the port, you'll have to use port 80, as it's the standard for the http:// scheme. The browser doesn't magically know on what port a given service is running nor it scans all of them.
Also, the .dev tld is also a real domain and will most likely cause problems.

apache2 reverse proxy with domain

I'm not sure if it's possible what I'm trying to do but I have a few applications on multiple servers. I have one server for gitlab, one for jenkins and one for sonarqube. I want to be able to navigate to them by using my domain as follows:
gitlab > https:// git.mydomain.com
jenkins > https:// jenkins.mydomain.com
sonarqube > http:// sonar.mydomain.com
What I'm trying to do is setup a reverse proxy with apache2 on a 4th server that runs independent from the applications. Here is what I tried to do:
<VirtualHost *:80>
ServerName http:// mydomain.com
ProxyPass http:// sonar.mydomain.com/ http:// sonar.mydomain.com:9000/
ProxyPassReverse http:// sonar.mydomain.com http:// sonar.mydomain.com:9000/
ProxyPass http:// jenkins.mydomain.com/ https:// jenkins.mydomain.com:8081/
ProxyPassReverse http:// jenkins.mydomain.com/ https:// jenkins.mydomain.com:8081/
</VirtualHost>
When I do it this way it won't work it will just go to the apache default page. What I did try is doing it with / and I noticed that it won't work with https:// extentions no matter in what way I try to set it. Is there a way to get this working?
and is it possible to set the proxy up the way I want?
Just create three name-based virtualhosts and use "/" as the first parameter for ProxyPass. Each vhost proxies to the corrsponding app.

I cann't call my localhost by ip address

I am trying to call my xampp localhost from another computer's browser, I have changed host file at C:\Windows\System32\Drivers\etc by appending (192.168.1.105 localhost) at the end this file and save it and then restart computer, but I could not call my localhost from another computer.
Thanks
You need to access port forwarding in your router and forward port 80 only as TCP. Also, the host file code should look something like YOUR IP YOUR IP and not YOUR IP localhost. Furthermore, you need to edit httpd-vhosts.conf from apache folder in xampp instalation with something like that
<VirtualHost *:80>
ServerAdmin whatever#whatever.com
DocumentRoot "PATH TO YOUR FOLDER"
ServerName YOUR IP
ServerAlias YOUR IP
</VirtualHost>
After that you must restart apache in XAMPP control panel (MySQL not necessary)
THE SOLUTION ABOVE WILL LET YOU SEE YOUR CONTENT FROM ANYWHERE AS LONG AS YOUR LOCAL PC IS TURNED ON AND HAVE INTERNET CONNECTION. THE SOLUTION BELOW (I DIDN'T TEST IT, BUT I GUESS IT WILL WORK) WILL LET YOU ACCESS YOUR CONTENT FROM LOCAL NETWORK ONLY.
edit your httpd-xampp.conf file as following and after that you should probably need to perform a browser cache cleaning
# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
Order deny,allow
#Deny from all
#Allow from 127.0.0.0/8
Allow from all
ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var
</LocationMatch>
When you add 192.168.1.105 localhost on the other PC (the one you want to use to view your website), it will look for a website on the same machine. Delete the entry from the hosts file and enter the IP address in your browser and it should work if the webserver is running.

Virtual host in laravel-4

How Can i setup virtual host for laravel-4 ?
Previously I wrote some code and routes looked like -
Route::get('/', 'PageController#home');
Route::get('/home', 'PageController#about');
when I gave the url - "http://localhost/laravel-master/public/" I can see the home page but when tired "http://localhost/laravel-master/public/about" i got error saying url not found.
I tired configuring virtual host but ended up with the error - You don't have permission to access"url" on this server.
What is the correct way to do this ??
the path to my laravel folder is "C:\wamp\www\laravel-master"
and instead of using "http://localhost/laravel-master/public/" i wish to use url like "myapp" or so, So that when i use myapp I can see the home page and when I use "myapp/about" I can see the about page.
You need to add your virtualhost and host file.Make your apache listen to your Url.
Something like in your virtualhost file
<VirtualHost laravel>
DocumentRoot "C:/wamp/www/laravel-master/public"
ServerName laravel
</VirtualHost>
And in your host file:
127.0.0.2 laravel
make apache restart and your clean URL will work.

Issue with Virtual Host on Zend Server CE and Mac OSX

I'm using Zend Server CE 5.6.0 on Mac OSX.
My httpd.conf has the following line, adding the virtual hosts file:
Include conf/extra/httpd-vhosts.conf
At that file, I have the following:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localtextil.drupal.lh
DocumentRoot /usr/local/zend/apache2/htdocs/Obiz/LocalTextil-Portal/drupal
</VirtualHost>
So, by definition, when I try to access localtextil.drupal.lh, it should redirect me to its document root.
The problem is, when I try to access that host, I got an error.
And when I simply access localhost, I go to the site located on /usr/local/zend/apache2/htdocs/Obiz/LocalTextil-Portal/drupal.
What am I doing wrong here?
Two things - first is that the virtualhost definitions (as I understand it) override apache's mappings between directories and servernames. The first defined virtualhost is what apache will use as a default when it can't find a map - so it should be a generic setup (reflecting your original domainname, in your case, localhost) first, then your specific setup following it.
Second is that if your folder is outside of where you have given apache permissions to read, then you may get an error. The directory permissions are set by a DocumentRoot directive - however:
Now when a request arrives, the server will first check if it is using an IP address that matches the NameVirtualHost. If it is, then
it will look at each section with a matching IP address
and try to find one where the ServerName or ServerAlias matches the
requested hostname. If it finds one, then it uses the configuration
for that server. If no matching virtual host is found, then the first
listed virtual host that matches the IP address will be used.
As a consequence, the first listed virtual host is the default virtual
host. The DocumentRoot from the main server will never be used when an
IP address matches the NameVirtualHost directive. If you would like to
have a special configuration for requests that do not match any
particular virtual host, simply put that configuration in a
container and list it first in the configuration file.
The Apache document page on name based virtual hosting is here, it should help give some ideas. Basically you need to look at the definitions you have for DocumentRoot and the servernames, and go through them making sure they are all "ok".

Resources