Home  >  Q&A  >  body text

nginx image 404 directs to another domain name

When requesting pictures on nginx, sometimes the request does not receive 404. The current domain name is stg.xxx.com.
How to configure it so that when 404 occurs, nginx automatically reverse-proxyes to onlone.xxx.com to ensure image response. .

Thanks!

大家讲道理大家讲道理2713 days ago398

reply all(1)I'll reply

  • 世界只因有你

    世界只因有你2017-05-16 17:17:17

    location = /40x.html{
        proxy_pass http://google.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;
    }

    You can try it, I haven’t tested it yet. This answer is based on previous experience.

    reply
    0
  • Cancelreply