Last active
October 8, 2024 08:14
-
-
Save refringe/6545132 to your computer and use it in GitHub Desktop.
Nginx configuration file example for Sendy (http://sendy.co/).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
listen [::]:80; | |
server_name domain.com; | |
autoindex off; | |
index index.php index.html; | |
root /srv/www/domain.com/public; | |
access_log /srv/www/domain.com/logs/access.log; | |
error_log /srv/www/domain.com/logs/error.log; | |
location / { | |
try_files $uri $uri/ $uri.php?$args; | |
} | |
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 /unsubscribe/ { | |
rewrite ^/unsubscribe/(.*)$ /unsubscribe.php?i=$1 last; | |
} | |
location /subscribe/ { | |
rewrite ^/subscribe/(.*)$ /subscribe.php?i=$1 last; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
} | |
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ { | |
access_log off; | |
log_not_found off; | |
expires 30d; | |
} | |
} |
You do realise this is extremely bad practice as you are exposing your http configuration to the world by placing it in your www root directory?
You do realise this is extremely bad practice as you are exposing your http configuration to the world by placing it in your www root directory?
Thanks for catching this!. Not sure how the files are served in nginx.
Moved it to a different folder.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to everyone who contributed to this.
For anyone that is hosting in Azure App Service for Linux which uses nginx,
What I would advise is to first copy the original nginx file and then edit it based on the config above.
First:
cp /etc/nginx/sites-available/default /home/site/default
The above will copy the default file from the
etc/nginx/sites-available
to your deployment folder.For example, this is what I got:
Then we can edit it based on the config shared above.
*Note, the main
location / ...
should include what you had from the original file. I went through pain because of this.Also, the config for
location ~* [^/]\.php(/|$) {....
should be keptFinal config is:
Then run
cp /home/site/default /etc/nginx/sites-available/default && service nginx restart
via SSHAnd also add
cp /home/site/default /etc/nginx/sites-available/default && service nginx restart
in the Startup Command under Configuration in your Azure Portal