Last active
October 8, 2024 08:19
-
-
Save elfico/356cec3d896e7038a7c240c307028ed7 to your computer and use it in GitHub Desktop.
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
For anyone that is hosting Sendy 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: | |
``` | |
server { | |
#proxy_cache cache; | |
#proxy_cache_valid 200 1s; | |
listen 8080; | |
listen [::]:8080; | |
root /home/site/wwwroot; | |
index index.php index.html index.htm; | |
server_name example.com www.example.com; | |
port_in_redirect off; | |
location / { | |
index index.php index.html index.htm hostingstart.html; | |
} | |
# redirect server error pages to the static page /50x.html | |
# | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /html/; | |
} | |
# Disable .git directory | |
location ~ /\.git { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
# Add locations of phpmyadmin here. | |
location ~* [^/]\.php(/|$) { | |
fastcgi_split_path_info ^(.+?\.[Pp][Hh][Pp])(|/.*)$; | |
fastcgi_pass 127.0.0.1:9000; | |
include fastcgi_params; | |
fastcgi_param HTTP_PROXY ""; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_param QUERY_STRING $query_string; | |
fastcgi_intercept_errors on; | |
fastcgi_connect_timeout 300; | |
fastcgi_send_timeout 3600; | |
fastcgi_read_timeout 3600; | |
fastcgi_buffer_size 128k; | |
fastcgi_buffers 4 256k; | |
fastcgi_busy_buffers_size 256k; | |
fastcgi_temp_file_write_size 256k; | |
} | |
} | |
``` | |
Then we can edit it based on the config shared above. | |
*Note, the main `location / ...` should include what you had from the original file. | |
Also, the config for `location ~* [^/]\.php(/|$) {....` should be kept | |
Final config is: | |
``` | |
server { | |
#proxy_cache cache; | |
#proxy_cache_valid 200 1s; | |
listen 8080; | |
listen [::]:8080; | |
root /home/site/wwwroot; | |
index index.php index.html index.htm; | |
server_name www.example.com; | |
autoindex off; | |
port_in_redirect off; | |
location / { | |
index index.php index.html index.htm hostingstart.html; #make sure to include this | |
try_files $uri $uri/ $uri.html $uri.php$is_args$query_string; | |
} | |
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 /confirm/ { | |
rewrite ^/confirm/(.*)$ /confirm.php?i=$1 last; | |
} | |
# redirect server error pages to the static page /50x.html | |
# | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /html/; | |
} | |
# Disable .git directory | |
location ~ /\.git { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
# Did not replace this | |
location ~* [^/]\.php(/|$) { | |
fastcgi_split_path_info ^(.+?\.[Pp][Hh][Pp])(|/.*)$; | |
fastcgi_pass 127.0.0.1:9000; | |
include fastcgi_params; | |
fastcgi_param HTTP_PROXY ""; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_param QUERY_STRING $query_string; | |
fastcgi_index index.php; | |
fastcgi_intercept_errors on; | |
fastcgi_connect_timeout 300; | |
fastcgi_send_timeout 3600; | |
fastcgi_read_timeout 3600; | |
fastcgi_buffer_size 128k; | |
fastcgi_buffers 4 256k; | |
fastcgi_busy_buffers_size 256k; | |
fastcgi_temp_file_write_size 256k; | |
} | |
location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|xml)$ { | |
access_log off; | |
log_not_found off; | |
expires 30d; | |
} | |
} | |
``` | |
Then run `cp /home/site/default /etc/nginx/sites-available/default && service nginx restart` via SSH | |
And also add `cp /home/site/default /etc/nginx/sites-available/default && service nginx restart` in the Startup Command under Configuration in your Azure Portal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment