Skip to content

Instantly share code, notes, and snippets.

@nathanielvarona
Last active May 23, 2019 20:41
Show Gist options
  • Save nathanielvarona/f0d6c501fffcfbcae683 to your computer and use it in GitHub Desktop.
Save nathanielvarona/f0d6c501fffcfbcae683 to your computer and use it in GitHub Desktop.
Sendy NGINX Configuration works with Sendy 2 and NGINX 1.8 https://sendy.co/
server {
#listen 80;
#listen [::]:80;
server_name sub.domain.tld;
access_log /var/log/sendy/nginx.access.log;
error_log /var/log/sendy/nginx.error.log;
root /opt/sendy;
autoindex off;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args ;
if (!-f $request_filename){
rewrite ^/([a-zA-Z0-9-]+)$ /$1.php last;
}
}
location /l/ {
rewrite ^/l/([a-zA-Z0-9/]+)$ /l.php?i=$1 last;
}
location /t/ {
rewrite ^/t/([a-zA-Z0-9/]+)$ /t.php?i=$1 last;
}
location /w/ {
rewrite ^/w/([a-zA-Z0-9/]+)$ /w.php?i=$1 last;
}
location /subscribe/ {
rewrite ^/subscribe/(.*)$ /subscribe.php?i=$1 last;
}
location /unsubscribe/ {
rewrite ^/unsubscribe/(.*)$ /unsubscribe.php?i=$1 last;
}
location /confirm/ {
rewrite ^/confirm/(.*)$ /confirm.php?i=$1 last;
}
location ~ \.php$ {
expires off;
fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME /opt/sendy$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 1200;
send_timeout 1200;
proxy_read_timeout 1200;
keepalive_timeout 0;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
access_log off;
log_not_found off;
expires max;
}
location ~* /\.ht {
deny all;
access_log off;
log_not_found off;
}
}
@ondrique
Copy link

Great, thanks for this.

@agarzon
Copy link

agarzon commented Jun 22, 2018

Yeap, this one works. Thank you.

The trick relies in the required redirections, so taking it from the htaccess file, that means:

     location / {
         try_files $uri $uri/ /index.php?$args ;
         if (!-f $request_filename){
             rewrite ^/([a-zA-Z0-9-]+)$ /$1.php last;
         }
     }   
 
     location /l/ {
         rewrite ^/l/([a-zA-Z0-9/]+)$ /l.php?i=$1 last;
     }
 
     location /t/ {
         rewrite ^/t/([a-zA-Z0-9/]+)$ /t.php?i=$1 last;
     }
     
     location /w/ {
         rewrite ^/w/([a-zA-Z0-9/]+)$ /w.php?i=$1 last;
     }
     
     location /subscribe/ {
         rewrite ^/subscribe/(.*)$ /subscribe.php?i=$1 last;
     }
     
     location /unsubscribe/ {
         rewrite ^/unsubscribe/(.*)$ /unsubscribe.php?i=$1 last;
     }
     
     location /confirm/ {
         rewrite ^/confirm/(.*)$ /confirm.php?i=$1 last;
     }

@cartpauj
Copy link

What is the purpose of?

         if (!-f $request_filename){
             rewrite ^/([a-zA-Z0-9-]+)$ /$1.php last;
         }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment