D
D
darkrain2020-06-16 12:34:50
Nginx
darkrain, 2020-06-16 12:34:50

Running laravel app through proxy_pass how?

There is a personal account on laravel, it works with finances and hangs on a separate server. Now it hangs on the invest.domain.com subdomain, but there is an urgent need to transfer it to the main domain where the main site (separate server) hangs in domain.com/invest.

All this is done through proxy_pass.

location /invest/ {
  proxy_pass http://ip.ip.ip.ip/;
    }


This will only work if you make relative links or write the link manually, I somehow solved this by redefining the following functions:
function route($name, $parameters = [], $absolute = true)
{

    return $_ENV['APP_URL'].app('url')->route($name, $parameters, false);
}

function asset($path, $secure = null)
{

    return $_ENV['APP_URL'].'/'.$path;
}


function appurl($path = null)
{
    return $_ENV['APP_URL'].$path;
}


function action($name, $parameters = [], $absolute = true)
{
    return $_ENV['APP_URL'].app('url')->action($name, $parameters, false);
}


Everything works except for redirects after processing forms, it redirects to the ip of the application server, and not the main server.

How can I do all this more correctly? Because I understand that this is not very reliable and hardcore

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2020-06-16
@ky0

More correctly - through proxy_pass with the transfer of the Host header. In general, what to proxy through nginx does not matter, the configuration is approximately the same.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question