Title: NGINX config
Last modified: August 30, 2016

---

# NGINX config

 *  [volga629](https://wordpress.org/support/users/volga629/)
 * (@volga629)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/nginx-config/)
 * Hello Everyone,
    Having hard time get working on corp website with nginx webserver.
   I receive email then click in link and get 404. Is my question anything special
   need to be done in term redirection. you can tr you self send email from “Form
   section” Web Site: [http://skillsearchrecruiting.com](http://skillsearchrecruiting.com)
 * Here NINX config which I tried
 *     ```
       location /download/ {
            valid_referers none blocked skillsearchrecruiting.com *.skillsearchrecruiting.com;
            access_log   /var/log/nginx/skillsearchrecruiting-com_download.log  download;
            if ($invalid_referer) {
                return   403;
                error_page 403 /403_error.html;
            }
           #rewrite ^/download/ /$1/[0-9][0-9]+(/.*)$2.pdf break;
           rewrite ^/download/ /$1/\d+(/.*)$2.pdf break;
           allow all;
   
       }
   
       location ~* (.*\.pdf) {
           types { application/octet-stream .pdf; }
           default_type application/octet-stream;
       }
       ```
   
 * [https://wordpress.org/plugins/email-before-download/](https://wordpress.org/plugins/email-before-download/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [dtynan](https://wordpress.org/support/users/dtynan/)
 * (@dtynan)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/nginx-config/#post-6281304)
 * I don’t use NGINX, but I do know Apache really well. Are you sure your rewrite
   rules are correct? They don’t look like they are. I see only one capture (the
   parentheses) yet you are using $1 and $2 as if there is another capture. Also,
   shouldn’t your capture be on the left url and not on the right url? You capture
   parts of the url you want to use — and you do that on the left side because that’s
   the incoming URL, then you construct a new ulr on the right side and you use 
   $1, $2, etc. for any URL parts you captured on the left side.
 * Do you even need to do a rewrite? I suspect it will break things to rewrite the
   download directory. Is that in effect right now on your Forms page or? Depending
   on the version of Download Monitor you are using, EBD will access files in different
   ways. Sometimes it does like an http get back to itself & other times it just
   reads the file directly off the disk. If the URL has been modified via rewrites,
   the EBD may have problems. I don’t know that it will – just guessing based on
   the code.
 * I did get the email with the download link in it, and the download didn’t work(
   404). I think you should turn on attachments in the EBD settings & then try again.
   That will help narrow things down — if the attachment goes shows up, then we 
   know the whole installation is messed up .. if no attachment shows up the you’re
   looking at uninstalling all the EBD-related plugins & starting over, reinstalling
   them and TESTING along the way as the instructions suggest. If you do end up 
   doing that, then I suggest using completely brand new filenames & titles — don’t
   repeat any of the ones you’ve already used because the data will still be in 
   the database & it might confuse things. For testing purposes, just make things
   simple — upload a jpg and call it “apple” and another jpg and call it “orange”.
   Don’t use any punctuation or special characters or non-English.
 *  Thread Starter [volga629](https://wordpress.org/support/users/volga629/)
 * (@volga629)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/nginx-config/#post-6281317)
 * Thank you for reply. That was pure guess. Then I realized that PHP does initial
   redirection. Is download/id folder should be static exist on disk ? How is working?
 * I tried ad something like this, but didn’t worked.
 *     ```
       location ~ "^/download/([0-9]{2})$" {
            internal;
            add_header Content-disposition "attachment; filename=$1";
       }
       ```
   
 *  Thread Starter [volga629](https://wordpress.org/support/users/volga629/)
 * (@volga629)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/nginx-config/#post-6281318)
 * is it matter [contact-form-7 id=”67″ title=”Download”] and actual folder is 71
 *  [dtynan](https://wordpress.org/support/users/dtynan/)
 * (@dtynan)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/nginx-config/#post-6281328)
 * You should not be doing a rewrite — it works without that, that’s just gonna 
   mess it up probably.
 * I looked through your HTML more closely and I noticed that every download is 
   download_id =3. I don’t know if you did that on purpose or not (maybe for testing?).
   Also, file 6 and file 7 have the descriptions switch .. so download_id 6 actually
   says it’s 7 on the screen.
 * Anyway, your page is way too complicated to figure out what’s happening. I don’t
   know if you removed the rewrite’s like I asked in my prior response. It doesn’t
   look like you enabled Attachments in EBD like I asked either, because I just 
   tried it and got an email and there no attachments (unless that’s just not working).
 * Your shortcode looked fine. There is no relationship between the ID in the shortcode(
   which is the ID of your Contact Form 7 form that you made) & the file download
   directories that Download Monitor uses when you download a file (and those numbers
   may not even be visible, depending on how you’ve configured things).
 * I cannot help you with you have things right now — there are way too many possible
   problems & I can’t tell what you are changing, if anything.
 * I suggest you leave that page as it is and don’t mess with it for a little while.
   Instead, go create a NEW Contact Form and configure like the EBD instructions
   mention. Upload 1 and only 1 new file and make it a .jpg file and name it “apple”
   or some name that you have NEVER used before. Create a NEW page in WordPress.
   On that page, put a shortcode like you did before, but it should have the ID 
   of the NEW Contact Form you just made & the Download ID of the NEW jpg file you
   just uploaded. Do not use any of your existing pages, or contact forms, or uploaded
   files — you can leave the plugins installed, but I want you to create a new page,
   new contact form, new upload, new shortcode. Don’t add anything else. Do NOT 
   put a bunch of javascript in there to make a popup. We want this to be super 
   simple. Do not put in a bunch of custom stuff.
 * Once you set all that up, make sure you do not have any rewrite rules – you should
   not need them. Now give it a shot & see if it works. Post back & let me know 
   what happened & put the URL in so I can try it.
 *  Thread Starter [volga629](https://wordpress.org/support/users/volga629/)
 * (@volga629)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/nginx-config/#post-6281334)
 * Thanks for reply. Yes I removed all redirect or rewrites from nginx. Right now
   it has config pasted from previous post. I will try add another download as you
   instructed.
 *  [dtynan](https://wordpress.org/support/users/dtynan/)
 * (@dtynan)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/nginx-config/#post-6281445)
 * ok let us know how it goes

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘NGINX config’ is closed to new replies.

 * ![](https://ps.w.org/email-before-download/assets/icon-256x256.jpg?rev=1813522)
 * [Email Before Download](https://wordpress.org/plugins/email-before-download/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/email-before-download/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/email-before-download/)
 * [Active Topics](https://wordpress.org/support/plugin/email-before-download/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/email-before-download/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/email-before-download/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [dtynan](https://wordpress.org/support/users/dtynan/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/nginx-config/#post-6281445)
 * Status: not resolved