Z
Z
zhanseitaliev2021-03-03 09:24:55
Nginx
zhanseitaliev, 2021-03-03 09:24:55

How to remove part of a link from nginx?

Hello! There is a laravel application configured in docker-compose.
Nginx redirects all /backend requests to the laravel application. Problem when using package horizon.
Horizon defaults to /horizon. I tried to change the default horizon link in the settings to /backend/horizon. The page loads but all css and js files are loaded from /vendor. How can I remove the /backend part of the link so that the laravel application receives data without the /backend prefix.

nginx conf

server {
  listen 80;

  index index.php index.html;
  root /var/www/html/public;

    location / {
        proxy_pass http://frontend:3001;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location /images/logo.svg {
        proxy_pass http://frontend:3001/logo-2.svg;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location /_next {
        proxy_pass http://frontend:3001/_next;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass backend:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    location /backend {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location /grafana {
        proxy_pass http://grafana:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}


603f2b5247ea7557671422.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question