LARAVEL serve on a ip but let laravel think its on a domain










0















I'm running laravel serve on a local ip, and using a local ProxyPass server to reverse a public domain to that local ip.



The only problem is that when im using asset('...') laravel is placing the ip in front of the location of that asset. This will result in a 404 for that requested file.



Example:
php artisan serve --host=192.168.178.2 --port=1234



My ProxyPass server passes all requests from example.com tot that local server.



This works, but on the places where I have used asset('...') in my code there is not 'example.com/css/app.css' but is '192.168.178.2/css/app.css'



Is there a way to serve on a IP, but laravel thinks its on a domain?










share|improve this question






















  • Does anything here help you? stackoverflow.com/questions/29912997/…

    – Mike
    Nov 15 '18 at 23:41











  • Also try setting ProxyPreserveHost On in your Apache config file. That might be easier than anything else there.

    – Mike
    Nov 15 '18 at 23:45











  • Thanks for the link, sadly that code is for 5.5, i'm on 5.7 and there is no routes.php file there. But I think that may be the solution, just not to my version. I dont want my proxy server to change content that it is pushing trough. Laravel needs to do that. And I don't think ProxyPreserveHost On will work. Because larvel is setting that ip in the code, not my proxy or php artisan serve.

    – UNTITLED.PNG
    Nov 15 '18 at 23:49











  • I need this for Laravel 5.7: link but I don't have the routes.php file

    – UNTITLED.PNG
    Nov 15 '18 at 23:53











  • ProxyPreserveHost On is precisely to retain the requested hostname when proxying. It does not change the content. Give that a try and get back to me.

    – Mike
    Nov 15 '18 at 23:55















0















I'm running laravel serve on a local ip, and using a local ProxyPass server to reverse a public domain to that local ip.



The only problem is that when im using asset('...') laravel is placing the ip in front of the location of that asset. This will result in a 404 for that requested file.



Example:
php artisan serve --host=192.168.178.2 --port=1234



My ProxyPass server passes all requests from example.com tot that local server.



This works, but on the places where I have used asset('...') in my code there is not 'example.com/css/app.css' but is '192.168.178.2/css/app.css'



Is there a way to serve on a IP, but laravel thinks its on a domain?










share|improve this question






















  • Does anything here help you? stackoverflow.com/questions/29912997/…

    – Mike
    Nov 15 '18 at 23:41











  • Also try setting ProxyPreserveHost On in your Apache config file. That might be easier than anything else there.

    – Mike
    Nov 15 '18 at 23:45











  • Thanks for the link, sadly that code is for 5.5, i'm on 5.7 and there is no routes.php file there. But I think that may be the solution, just not to my version. I dont want my proxy server to change content that it is pushing trough. Laravel needs to do that. And I don't think ProxyPreserveHost On will work. Because larvel is setting that ip in the code, not my proxy or php artisan serve.

    – UNTITLED.PNG
    Nov 15 '18 at 23:49











  • I need this for Laravel 5.7: link but I don't have the routes.php file

    – UNTITLED.PNG
    Nov 15 '18 at 23:53











  • ProxyPreserveHost On is precisely to retain the requested hostname when proxying. It does not change the content. Give that a try and get back to me.

    – Mike
    Nov 15 '18 at 23:55













0












0








0








I'm running laravel serve on a local ip, and using a local ProxyPass server to reverse a public domain to that local ip.



The only problem is that when im using asset('...') laravel is placing the ip in front of the location of that asset. This will result in a 404 for that requested file.



Example:
php artisan serve --host=192.168.178.2 --port=1234



My ProxyPass server passes all requests from example.com tot that local server.



This works, but on the places where I have used asset('...') in my code there is not 'example.com/css/app.css' but is '192.168.178.2/css/app.css'



Is there a way to serve on a IP, but laravel thinks its on a domain?










share|improve this question














I'm running laravel serve on a local ip, and using a local ProxyPass server to reverse a public domain to that local ip.



The only problem is that when im using asset('...') laravel is placing the ip in front of the location of that asset. This will result in a 404 for that requested file.



Example:
php artisan serve --host=192.168.178.2 --port=1234



My ProxyPass server passes all requests from example.com tot that local server.



This works, but on the places where I have used asset('...') in my code there is not 'example.com/css/app.css' but is '192.168.178.2/css/app.css'



Is there a way to serve on a IP, but laravel thinks its on a domain?







php laravel proxy proxypass serve






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 23:36









UNTITLED.PNGUNTITLED.PNG

91110




91110












  • Does anything here help you? stackoverflow.com/questions/29912997/…

    – Mike
    Nov 15 '18 at 23:41











  • Also try setting ProxyPreserveHost On in your Apache config file. That might be easier than anything else there.

    – Mike
    Nov 15 '18 at 23:45











  • Thanks for the link, sadly that code is for 5.5, i'm on 5.7 and there is no routes.php file there. But I think that may be the solution, just not to my version. I dont want my proxy server to change content that it is pushing trough. Laravel needs to do that. And I don't think ProxyPreserveHost On will work. Because larvel is setting that ip in the code, not my proxy or php artisan serve.

    – UNTITLED.PNG
    Nov 15 '18 at 23:49











  • I need this for Laravel 5.7: link but I don't have the routes.php file

    – UNTITLED.PNG
    Nov 15 '18 at 23:53











  • ProxyPreserveHost On is precisely to retain the requested hostname when proxying. It does not change the content. Give that a try and get back to me.

    – Mike
    Nov 15 '18 at 23:55

















  • Does anything here help you? stackoverflow.com/questions/29912997/…

    – Mike
    Nov 15 '18 at 23:41











  • Also try setting ProxyPreserveHost On in your Apache config file. That might be easier than anything else there.

    – Mike
    Nov 15 '18 at 23:45











  • Thanks for the link, sadly that code is for 5.5, i'm on 5.7 and there is no routes.php file there. But I think that may be the solution, just not to my version. I dont want my proxy server to change content that it is pushing trough. Laravel needs to do that. And I don't think ProxyPreserveHost On will work. Because larvel is setting that ip in the code, not my proxy or php artisan serve.

    – UNTITLED.PNG
    Nov 15 '18 at 23:49











  • I need this for Laravel 5.7: link but I don't have the routes.php file

    – UNTITLED.PNG
    Nov 15 '18 at 23:53











  • ProxyPreserveHost On is precisely to retain the requested hostname when proxying. It does not change the content. Give that a try and get back to me.

    – Mike
    Nov 15 '18 at 23:55
















Does anything here help you? stackoverflow.com/questions/29912997/…

– Mike
Nov 15 '18 at 23:41





Does anything here help you? stackoverflow.com/questions/29912997/…

– Mike
Nov 15 '18 at 23:41













Also try setting ProxyPreserveHost On in your Apache config file. That might be easier than anything else there.

– Mike
Nov 15 '18 at 23:45





Also try setting ProxyPreserveHost On in your Apache config file. That might be easier than anything else there.

– Mike
Nov 15 '18 at 23:45













Thanks for the link, sadly that code is for 5.5, i'm on 5.7 and there is no routes.php file there. But I think that may be the solution, just not to my version. I dont want my proxy server to change content that it is pushing trough. Laravel needs to do that. And I don't think ProxyPreserveHost On will work. Because larvel is setting that ip in the code, not my proxy or php artisan serve.

– UNTITLED.PNG
Nov 15 '18 at 23:49





Thanks for the link, sadly that code is for 5.5, i'm on 5.7 and there is no routes.php file there. But I think that may be the solution, just not to my version. I dont want my proxy server to change content that it is pushing trough. Laravel needs to do that. And I don't think ProxyPreserveHost On will work. Because larvel is setting that ip in the code, not my proxy or php artisan serve.

– UNTITLED.PNG
Nov 15 '18 at 23:49













I need this for Laravel 5.7: link but I don't have the routes.php file

– UNTITLED.PNG
Nov 15 '18 at 23:53





I need this for Laravel 5.7: link but I don't have the routes.php file

– UNTITLED.PNG
Nov 15 '18 at 23:53













ProxyPreserveHost On is precisely to retain the requested hostname when proxying. It does not change the content. Give that a try and get back to me.

– Mike
Nov 15 '18 at 23:55





ProxyPreserveHost On is precisely to retain the requested hostname when proxying. It does not change the content. Give that a try and get back to me.

– Mike
Nov 15 '18 at 23:55












1 Answer
1






active

oldest

votes


















0














I found the solution, thanks to Mike!

Because of the old Stack Overflow post he advised me to visit. I found some new search terms for google. And then I found a GitHub post that just works with the latest Laravel 5.7.



Add the following code to app/Providers/RouteServiceProvider.php



public function boot()

parent::boot();

/** @var IlluminateRoutingUrlGenerator $url */
$url = $this->app['url'];
// Force the application URL
$url->forceRootUrl(config('app.url'));






share|improve this answer

























  • You should add the relevant code here. Link-only answers are frowned upon.

    – Mike
    Nov 16 '18 at 0:16










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53329364%2flaravel-serve-on-a-ip-but-let-laravel-think-its-on-a-domain%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I found the solution, thanks to Mike!

Because of the old Stack Overflow post he advised me to visit. I found some new search terms for google. And then I found a GitHub post that just works with the latest Laravel 5.7.



Add the following code to app/Providers/RouteServiceProvider.php



public function boot()

parent::boot();

/** @var IlluminateRoutingUrlGenerator $url */
$url = $this->app['url'];
// Force the application URL
$url->forceRootUrl(config('app.url'));






share|improve this answer

























  • You should add the relevant code here. Link-only answers are frowned upon.

    – Mike
    Nov 16 '18 at 0:16















0














I found the solution, thanks to Mike!

Because of the old Stack Overflow post he advised me to visit. I found some new search terms for google. And then I found a GitHub post that just works with the latest Laravel 5.7.



Add the following code to app/Providers/RouteServiceProvider.php



public function boot()

parent::boot();

/** @var IlluminateRoutingUrlGenerator $url */
$url = $this->app['url'];
// Force the application URL
$url->forceRootUrl(config('app.url'));






share|improve this answer

























  • You should add the relevant code here. Link-only answers are frowned upon.

    – Mike
    Nov 16 '18 at 0:16













0












0








0







I found the solution, thanks to Mike!

Because of the old Stack Overflow post he advised me to visit. I found some new search terms for google. And then I found a GitHub post that just works with the latest Laravel 5.7.



Add the following code to app/Providers/RouteServiceProvider.php



public function boot()

parent::boot();

/** @var IlluminateRoutingUrlGenerator $url */
$url = $this->app['url'];
// Force the application URL
$url->forceRootUrl(config('app.url'));






share|improve this answer















I found the solution, thanks to Mike!

Because of the old Stack Overflow post he advised me to visit. I found some new search terms for google. And then I found a GitHub post that just works with the latest Laravel 5.7.



Add the following code to app/Providers/RouteServiceProvider.php



public function boot()

parent::boot();

/** @var IlluminateRoutingUrlGenerator $url */
$url = $this->app['url'];
// Force the application URL
$url->forceRootUrl(config('app.url'));







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 16 '18 at 0:31

























answered Nov 16 '18 at 0:07









UNTITLED.PNGUNTITLED.PNG

91110




91110












  • You should add the relevant code here. Link-only answers are frowned upon.

    – Mike
    Nov 16 '18 at 0:16

















  • You should add the relevant code here. Link-only answers are frowned upon.

    – Mike
    Nov 16 '18 at 0:16
















You should add the relevant code here. Link-only answers are frowned upon.

– Mike
Nov 16 '18 at 0:16





You should add the relevant code here. Link-only answers are frowned upon.

– Mike
Nov 16 '18 at 0:16



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53329364%2flaravel-serve-on-a-ip-but-let-laravel-think-its-on-a-domain%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

政党