Answer the question
In order to leave comments, you need to log in
Proxy_pass in Nginx - how to work with variables?
You need to receive a file via a link from another domain
https://site1.ru/link/pDK9VJacsrb9bway?no=2 - this is the main site, but I would like to receive a file via a mirror site https://site2.ru/link/pDK9VJacsrb9bway?no= 2
Main site config:
server {
root /var/www/site1.ru/public;
index index.php index.html;
server_name site1.ru;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
server {
index index.php index.html;
server_name site2.ru;
location / {
root /var/www/site2.ru;
}
location /link/ {
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass https://site1.ru:443/;
}
Answer the question
In order to leave comments, you need to log in
nginx.org/en/docs/http/ngx_http_proxy_module.html#...
If the proxy_pass directive is specified with a URI, then when the request is sent to the server, the part of the normalized request URI corresponding to location is replaced by the URI specified in the directive:
location /link/ {
proxy_pass https://site1.ru/;
/link/
it will be replaced by /
as a result https://site1.ru/pDK9VJacsrb9bway?no=2location /link/ {
proxy_pass https://site1.ru;
proxy_set_header Host $host;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question