There is a nginx config:

location /api/public/login/ { proxy_pass https://req.test.local/api/public/login/; proxy_max_temp_file_size 0; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; proxy_ssl_session_reuse off; proxy_set_header Host $http_host; proxy_redirect off; proxy_intercept_errors on; error_page 301 302 307 = @handle_redirect; } location /api/protected/new_mnp_request/ { proxy_pass https://req.test.local/api/protected/new_mnp_request/; proxy_max_temp_file_size 0; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; proxy_ssl_session_reuse off; proxy_set_header Host $http_host; proxy_redirect off; proxy_intercept_errors on; error_page 301 302 307 = @handle_redirect; } location @handle_redirect { set $orig_loc $upstream_http_location; proxy_pass $orig_loc; set $saved_redirect_location '$upstream_http_location'; set $original_uri $uri; set $orig_loc $upstream_http_location; proxy_cache_key $original_uri; proxy_hide_header Strict-Transport-Security; proxy_cache_valid 200 202 30h; expires 30h; access_log off; add_header Cache-Control "public"; etag off; add_header X-Proxy-Cache $upstream_cache_status; } 

https: //req.test.local - acts as a backend, spin on apache and is on the client side.

On the site, when a request is sent to the backend, the error in the nginx logs is:

 2018/11/05 23:06:18 [error] 130606#0: *3 invalid URL prefix in "", client: 10.10.8.28, server: 10.200.210.53, request: "GET /api/public/login?login=mnp_api&password=qs2b_kW%21afs HTTP/1.1", host: "test.local:3443", referrer: "https://test.local:3443/mnp/main" 2018/11/05 23:06:18 [error] 130607#0: *4 invalid URL prefix in "", client: 10.10.8.28, server: 10.200.210.53, request: "GET /api/protected/new_mnp_request?id_location=176&name=1111111111&surname=11111111111&ported_number=7081111111&email=111111111111%40nrer.34&id_lang=1&operator_type=07&patronymic=111111111111&contact_phone=%2B7%28111%29111-11-11 HTTP/1.1", host: "test.local:3443", referrer: "https://test.local:3443/mnp/main" 

Accordingly, proxying does not work and in the browser this error:

 :3443/api/public/login?login=mnp_api&password=qq2b_kW%21afs:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error) :3443/api/protected/new_mnp_request?id_location=176&name=1111111111&surname=11111111&ported_number=7081111111&email=admin%40test.com&id_lang=1&operator_type=07&patronymic=111111111111&contact_phone=%2B7%28111%29111-11-11:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error) 

I suspect that the error is due to https. When to send a request to the backend URL via curl, 301 redirect is triggered first, and then 200.

Then how to properly configure nginx to proxied correctly?

    0