AmiiboAPI
AmiiboAPI copied to clipboard
Trailing Slash issue with ngnix configuration
I will be posting my Nginx configuration to see if anyone can help solve this issue. Seems like it will add a trailing slash when and cause a redirect loop.
server {
listen 80;
listen [::]:80;
server_name amiiboapi.com www.amiiboapi.com;
location / {
add_header 'Access-Control-Allow-Origin' '*' always;
return 301 https://$server_name$request_uri;
}
}
server {
listen 443 ssl;
server_name amiiboapi.com www.amiiboapi.com;
location /api(.*)$ {
limit_req zone=mylimit;
proxy_pass http://client:8080/api$1$is_args$args;
proxy_redirect off;
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;
}
location / {
proxy_pass http://client:8080;
proxy_redirect off;
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;
}
ssl_certificate /etc/letsencrypt/live/certification.pem;
ssl_certificate_key /etc/letsencrypt/live/key.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
Could add rewrite ^/(.*)/$ /$1 permanent; to your server block if this is still an issue?
Could add
rewrite ^/(.*)/$ /$1 permanent;to your server block if this is still an issue?
Just tried that, seems to not work. Kinda cause the site to crash too.
Below are the 2 different methods I tried with the rewrite.
- Added on both server blocks.
- Added only to 443 listener.