0

I am trying to setup an Nginx reverse proxy to an AWS API Gateway address like https://12345.execute-api.eu-central-1.amazonaws.com/v2 behind a corporate proxy.

I tried the following setup to www.example.com and it works. But as soon as I add https to it like https://www.example.com it fails. I add https since my API Gateway address is not accessible without it.

Current working config:

server {
    listen 80;
    listen [::]:80;
    listen 443;
    underscores_in_headers on;
   
    location / {
        proxy_pass_request_headers      on;
        proxy_set_header Host www.example.com;
        proxy_pass  http://myCorporateProxy.org:8080;
    }
}

What I want to achieve and error I get: Redirect all incoming traffic to localhost to be redirected to API Gateway address which looks similar to https://123456.execute-api.region.amazonaws.com/v2/ When trying following config, I get a 302 temporarily Moved error. In configuration it would look like this:

server {
    listen 80;
    listen [::]:80;
    listen 443;
    underscores_in_headers on;
   
    location / {
        proxy_pass_request_headers      on;
        proxy_set_header Host https://www.example.com;
        proxy_pass  http://myCorporateProxy.org:8080;
    }
}
Zabih Khaliqi
  • 85
  • 1
  • 8

1 Answers1

0

You should try something like this. To redirect from http to https is a little different.

server {
    listen 80;
    server_name myCorporateProxy.org www.myCorporateProxy.org;
    return 301 https://myCorporateProxy.org$request_uri;
}
C.Gochev
  • 1,837
  • 11
  • 21
  • I tried this solution with various setups as follows none of them works. I basically tried the same setup by moving port number to different places. I also tried with and without location / { ... } part. – Zabih Khaliqi Aug 17 '21 at 13:22