edi

edi

send_file - SSL

Hello,
I just configured my app with SSL and i see that i have problem with downloading files. On my config i have this:

  force_ssl: [rewrite_on: [:x_forwarded_proto], host: "myapp.com"],
  load_from_system_env: true,
  url: [host: "myapp.com"],
  http: [port: 80],
  force_ssl: [hsts: true],
  https: [    
    port: 443,
    otp_app: :myapp,
    keyfile: Path.expand("/etc/letsencrypt/live/myapp.com/privkey.pem", __DIR__),
    certfile: Path.expand("/etc/letsencrypt/live/myapp.com/cert.pem", __DIR__),
    cacertfile: Path.expand("/etc/letsencrypt/live/myapp.com/fullchain.pem", __DIR__)
  ]

I have a route that I generate file and i send the file like this:

filename = "my/file/exists/here.pdf"
conn
|> put_resp_content_type("application/pdf", nil)
|> put_resp_header("content-transfer-encoding", "binary")
|> put_resp_header(
    "Content-Disposition",
    ~s[attachment; filename="file.pdf"]
)
|> send_file(200, filename)

The issue is because without SSL everything works fine, but when i added SSL in the route that i generate files, it doesn’t return the file.

Thanks

Most Liked

outlog

outlog

check that ssl is correct using https://www.ssllabs.com/ssltest/

NB you have multiple “force_ssl:” in your config you probably want:

force_ssl: [rewrite_on: [:x_forwarded_proto], hsts: true, host: “myapp.com”],

additionally you are using x_forwarded_proto which suggest you have something in front of the phoenix app? what is that? (nginx? etc?)

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New

We're in Beta

About us Mission Statement