Answer the question
In order to leave comments, you need to log in
How to proxy get parameters in nginx?
I have the following nginx configuration (simplified):
# Frontend
server {
listen *:443 ssl http2;
server_name example.com;
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-Host $server_name;
proxy_redirect off;
proxy_read_timeout 60s;
root /var/www/front;
location /api {
proxy_pass http://127.0.0.1:8888;
}
location / {
if (!-e $request_filename{
rewrite ^(.*)$ /index.html;
}
index index.html;
}
}
# Backend
server {
listen 127.0.0.1:8888;
root /var/www/api;
location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
location ~ \.php$ {
fastcgi_pass backend:9000;
fastcgi_index index.php;
fastcgi_cache fcgi;
fastcgi_cache_valid 200 30m;
include fastcgi_params;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
}
}
Answer the question
In order to leave comments, you need to log in
With proxy_pass, they are already proxied without loss as they are. And the problem is clearly elsewhere. Apparently the real config should be simplified to a really simple one.
In the project itself, API is being proxyed to a server in the internal network. Everything works great. There is even a change in the original url.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question