I have the following configuration for nginx in AWS source bundle.
location / {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Controller as below.
@GetMapping("/inputuploads")
public String listInputUploads(Model model) {
return "inputuploads";
}
@PostMapping("/inputuploads")
public String saveFile(Model model, @RequestParam("file") MultipartFile file, RedirectAttributes ra) throws IOException {
s3Service.uploadFile(file.getOriginalFilename().toLowerCase(), file);
ra.addFlashAttribute("message","Uploaded file: "+ file.getOriginalFilename());
return "redirect:/inputuploads";
}
Template as below.
<div >
<form method="post" th:action="@{/inputuploads}" enctype="multipart/form-data" >
<div>
<input type="file" name="file" accept=".xlsm" >
</div>
<div>
<button type="submit" >Upload</button>
</div>
</form>
</div>
The GET url is accessed through https and while submitting POST, after saving the file in S3, it is redirecting to http url instead of https.