[GH-ISSUE #190] Proxy pass with NGINX #82

Closed
opened 2026-02-25 22:34:19 +03:00 by kerem · 6 comments
Owner

Originally created by @yoldar on GitHub (Sep 13, 2018).
Original GitHub issue: https://github.com/flyimg/flyimg/issues/190

Hi! Thank you for that great tool!

I have a question. I'm using Flyimg as microservice as a part of docker-compose.yml. I have one global nginx which routes to each microservice. Flyimg is under /image-optimizer/ path. Here is global nginx config:

location /image-optimizer/ {
    proxy_pass http://image-optimizer:80/;
}

The problem is when global proxy passes something like
http://test.test/image-optimizer/upload/w_500,h_500,q_90/https://m0.cl/t/butterfly-3000.jpg
it removes double slash from https://

nginx logs from flyimg show this:
"GET /upload/w_500,h_500,q_90/https:/m0.cl/t/butterfly-3000.jpg HTTP/1.0" 500

I now that this question is related to nginx community but you are more in context :)

May be you could give an advise?

Originally created by @yoldar on GitHub (Sep 13, 2018). Original GitHub issue: https://github.com/flyimg/flyimg/issues/190 Hi! Thank you for that great tool! I have a question. I'm using Flyimg as microservice as a part of docker-compose.yml. I have one global nginx which routes to each microservice. Flyimg is under /image-optimizer/ path. Here is global nginx config: ``` location /image-optimizer/ { proxy_pass http://image-optimizer:80/; } ``` The problem is when global proxy passes something like `http://test.test/image-optimizer/upload/w_500,h_500,q_90/https://m0.cl/t/butterfly-3000.jpg ` it removes double slash from https:// nginx logs from flyimg show this: `"GET /upload/w_500,h_500,q_90/https:/m0.cl/t/butterfly-3000.jpg HTTP/1.0" 500` I now that this question is related to nginx community but you are more in context :) May be you could give an advise?
kerem 2026-02-25 22:34:19 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@baamenabar commented on GitHub (Sep 13, 2018):

This is good use case, thanks for sharing this with us.

My nginx is a bit rusty but I´ll give it a go. @sadok-f ? any ideas?

<!-- gh-comment-id:420909969 --> @baamenabar commented on GitHub (Sep 13, 2018): This is good use case, thanks for sharing this with us. My nginx is a bit rusty but I´ll give it a go. @sadok-f ? any ideas?
Author
Owner

@baamenabar commented on GitHub (Sep 13, 2018):

@yoldar . can you share a bit more of your nginx config? My quick guess is something else in that config might be stripping the slashes.

But first try adding: merge_slashes off above the proxy_pass line.

I don´t expect it to solve the problem, but we might get lucky.

<!-- gh-comment-id:420911623 --> @baamenabar commented on GitHub (Sep 13, 2018): @yoldar . can you share a bit more of your nginx config? My quick guess is something else in that config might be stripping the slashes. But first try adding: `merge_slashes off` above the `proxy_pass` line. I don´t expect it to solve the problem, but we might get lucky.
Author
Owner

@sadok-f commented on GitHub (Sep 13, 2018):

Thank you @yoldar for submitting the issue!

Well our demo website is running on nginx as proxy pass to a docker container.
Here the config:

server {
    server_name oi.flyimg.io;

    location / {
        proxy_pass http://localhost:8080;
    }
}

As suggetion maybe try to remove the tail slash in your config to become:

location /image-optimizer/ {
    proxy_pass http://image-optimizer:80;
}
<!-- gh-comment-id:420916265 --> @sadok-f commented on GitHub (Sep 13, 2018): Thank you @yoldar for submitting the issue! Well our demo website is running on nginx as proxy pass to a docker container. Here the config: ``` server { server_name oi.flyimg.io; location / { proxy_pass http://localhost:8080; } } ``` As suggetion maybe try to remove the tail slash in your config to become: ``` location /image-optimizer/ { proxy_pass http://image-optimizer:80; } ```
Author
Owner

@sadok-f commented on GitHub (Sep 13, 2018):

@yoldar I just reproduce the issue with Nginx, adding the trailing slash cause removing the double slash.
So remove the trailing slash and it'll work!

<!-- gh-comment-id:420923040 --> @sadok-f commented on GitHub (Sep 13, 2018): @yoldar I just reproduce the issue with Nginx, adding the trailing slash cause removing the double slash. So remove the trailing slash and it'll work!
Author
Owner

@yoldar commented on GitHub (Sep 13, 2018):

Thank you all for your replies!

While debugging this issue I have learned how to correctly write nginx rewrite regex rules :)

Solution is here:

location /image-optimizer/ {
    rewrite  ^/image-optimizer/upload/(.*)/(http:|https:)/(.*)  /upload/$1/$2//$3 break;
    proxy_pass http://image-optimizer:80;
}
<!-- gh-comment-id:420993773 --> @yoldar commented on GitHub (Sep 13, 2018): Thank you all for your replies! While debugging this issue I have learned how to correctly write nginx rewrite regex rules :) Solution is here: ``` location /image-optimizer/ { rewrite ^/image-optimizer/upload/(.*)/(http:|https:)/(.*) /upload/$1/$2//$3 break; proxy_pass http://image-optimizer:80; } ```
Author
Owner

@sadok-f commented on GitHub (Sep 13, 2018):

Great to know that you fixed it!
Thank you again for contributing with us!

<!-- gh-comment-id:420995927 --> @sadok-f commented on GitHub (Sep 13, 2018): Great to know that you fixed it! Thank you again for contributing with us!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/flyimg#82
No description provided.