0

I setup a Nginx reverse proxy virtual host as below:

location / {
    proxy_pass http://127.0.0.1:8082;
    proxy_set_header Host $host:$server_port;
    proxy_set_header X-Forwarded-Host $server_name;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

Now, I'd like to add a special file URL in the proxy upstream to a file in the nginx host file system, i.e.

rewrite /rwt-resources/themes/images/676b22ad.png /file/path/under/the/nginx/host.png permanent;

How to make it?

6
  • What happenned when you tested the change you proposed? How did this not meet your requirement? (I suspect that you don't want a HTTP redirect here, in which case use 'break' or 'last' rather than 'permanent'). And you're heading for a world of pain trying to content management in your webserver / proxy config.
    – symcbean
    Jun 26, 2023 at 9:31
  • I test, it failed for being not able to redirect to the nginx host local file path.
    – Vincent
    Jun 27, 2023 at 2:09
  • So you want one URL to not go to proxy_pass? Use location = /rwt-resources/themes/images/676b22ad.png { ... } Jun 27, 2023 at 9:45
  • @RichardSmith Thank you for your tip! I add a location before location /. However, it said 404 in the Developer tools. location /rwt-resources/themes/images/676b22ad.png { internal; alias /root/seb/; } location / { .......
    – Vincent
    Jun 28, 2023 at 13:27
  • internal will respond with 404 if the request is external - you should probably remove it. The alias statement should probably be alias /file/path/under/the/nginx/host.png; Jun 28, 2023 at 21:16

0

You must log in to answer this question.

Browse other questions tagged .