1

I am using proxy_pass directive to upstream https server. The proxy server is meant for LAN clients. However I have a problem with the upstream django application rejecting http POST requests due to a non-secure referer header

https://github.com/django/django/blob/9c9ef5835200a1bc6410d2769b9699baba9f9a8b/django/middleware/csrf.py#L249

Is it possible to rewrite http_referer header to https? example

 http://192.168.1.5/application/page -> https://upstream.backend/application/page
1

I'm more experienced with Apache. But the .conf files are much the same.

So, you basically want to rewrite all http reqeuests to https?

And 192.168.1.5 resolves to upstream.backend in your DNS?

If that's the case, and you are using the latest revisions, you would first need to generate a SSL certificate to use.. Easy enough, U assume you are using a linux distrubution, so i'll walk you through doing it via shell or ssh:

  1. cd /etc/nginx
  2. sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/cert.key -out /etc/nginx/cert.crt

at this point, put in your info, and a 2048 bit (unsigned) certificate will be generate and which you can use for nginx port 443. Since you are on a Local Network, purchasing a SSL certificate would be a waste.

From here you need to populate /etc/nginx/sites-enabled/default with all the above pertaining info like domains, locations of certs (be sure to tell nginx to listen to port 443).. the next step is for the proxy pass:

... location / {

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-Proto $scheme;

proxy_pass          http://192.168.1.5/application/page;
proxy_read_timeout  90;

proxy_redirect      http://192.168.1.5/application/page https://upstream.backend/application/page;

} ...

NOTE: This may or may not work, as I've skipped a couple things I wouldn't normally use. I would try this. If nginx doesn't life the "application/page" try just http://192.168.1.5 and https://upstream.backend.

If all else fails, lookup "jenkins" which i am not familiar with.

Cheers

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.