-
-
Save g011um/9f84612efbc18e5fc827b241a1e42b31 to your computer and use it in GitHub Desktop.
Serve multiple AtoM instances from a single host
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
# Modified version of the default nginx AtoM config file found here: | |
# https://www.accesstomemory.org/en/docs/2.4/admin-manual/installation/linux/ubuntu-xenial/ | |
# | |
# The default AtoM instructions assume a single instance served from a URL like: | |
# | |
# http://www.example.com/ | |
# | |
# This config is used to add additional instances served up like this: | |
# | |
# http://www.example.com/atom1 | |
# http://www.example.com/atom2 | |
# | |
upstream atom { | |
server unix:/run/php7.0-fpm.atom.sock; | |
} | |
# Additional PHP-FPM instances are required, one for each additional site | |
upstream atom1 { | |
server unix:/run/php7.0-fpm.atom1.sock; | |
} | |
upstream atom2 { | |
server unix:/run/php7.0-fpm.atom2.sock; | |
} | |
server { | |
listen 80; | |
root /usr/share/nginx/atom; | |
# http://wiki.nginx.org/HttpCoreModule#server_name | |
# _ means catch any, but it's better if you replace this with your server | |
# name, e.g. archives.foobar.com | |
server_name _; | |
client_max_body_size 72M; | |
# http://wiki.nginx.org/HttpCoreModule#try_files | |
location / { | |
try_files $uri /index.php?$args; | |
} | |
location ~ /\. { | |
deny all; | |
return 404; | |
} | |
location ~* (\.yml|\.ini|\.tmpl)$ { | |
deny all; | |
return 404; | |
} | |
location ~* /(?:uploads|files)/.*\.php$ { | |
deny all; | |
return 404; | |
} | |
location ~* /uploads/r/(.*)/conf/ { | |
} | |
location ~* ^/uploads/r/(.*)$ { | |
include /etc/nginx/fastcgi_params; | |
set $index /index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$index; | |
fastcgi_param SCRIPT_NAME $index; | |
fastcgi_pass atom; | |
} | |
location ~ ^/private/(.*)$ { | |
internal; | |
alias /usr/share/nginx/atom/$1; | |
} | |
location ~ ^/(index|qubit_dev)\.php(/|$) { | |
include /etc/nginx/fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_split_path_info ^(.+\.php)(/.*)$; | |
fastcgi_pass atom; | |
} | |
# This section of the oritinal AtoM config should be moved to the bottom | |
#location ~* \.php$ { | |
# deny all; | |
# return 404; | |
#} | |
####################################################################### | |
# So far the config is almost identical to the AtoM docs | |
# We will duplicate most of the above for each additional site served | |
####################################################################### | |
# -------------------------------------------------------------------------------- | |
# atom1 Config | |
# -------------------------------------------------------------------------------- | |
location /atom1 { | |
try_files $uri /atom1/index.php?$args; | |
} | |
location ~ /atom1/\. { | |
deny all; | |
return 404; | |
} | |
location ~* /atom1/(?:uploads|files)/.*\.php$ { | |
deny all; | |
return 404; | |
} | |
location ~* /atom1/uploads/r/(.*)/conf/ { | |
} | |
location ~* ^/atom1/uploads/r/(.*)$ { | |
root /usr/share/nginx/atom1; | |
include /etc/nginx/fastcgi_params; | |
set $index /index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$index; | |
fastcgi_param SCRIPT_NAME /atom1$index; | |
fastcgi_pass atom1; | |
} | |
location ~ ^/atom1/private/(.*)$ { | |
internal; | |
alias /usr/share/nginx/atom1/$1; | |
} | |
location ~ ^/atom1/(index|qubit_dev)\.php(/|$) { | |
root /usr/share/nginx/atom1 | |
include /etc/nginx/fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$1.php; | |
fastcgi_split_path_info ^(.+\.php)(/.*)$; | |
fastcgi_pass atom1; | |
} | |
# -------------------------------------------------------------------------------- | |
# End of atom1 site | |
# -------------------------------------------------------------------------------- | |
# -------------------------------------------------------------------------------- | |
# atom2 Config | |
# -------------------------------------------------------------------------------- | |
location /atom2 { | |
try_files $uri /atom2/index.php?$args; | |
} | |
location ~ /atom2/\. { | |
deny all; | |
return 404; | |
} | |
location ~* /atom2/(?:uploads|files)/.*\.php$ { | |
deny all; | |
return 404; | |
} | |
location ~* /atom2/uploads/r/(.*)/conf/ { | |
} | |
location ~* ^/atom2/uploads/r/(.*)$ { | |
root /usr/share/nginx/atom2; | |
include /etc/nginx/fastcgi_params; | |
set $index /index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$index; | |
fastcgi_param SCRIPT_NAME /atom2$index; | |
fastcgi_pass atom2; | |
} | |
location ~ ^/atom2/private/(.*)$ { | |
internal; | |
alias /usr/share/nginx/atom2/$1; | |
} | |
location ~ ^/atom2/(index|qubit_dev)\.php(/|$) { | |
root /usr/share/nginx/atom2 | |
include /etc/nginx/fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$1.php; | |
fastcgi_split_path_info ^(.+\.php)(/.*)$; | |
fastcgi_pass atom2; | |
} | |
# -------------------------------------------------------------------------------- | |
# End of atom1 site | |
# -------------------------------------------------------------------------------- | |
# This was moved from above to the end of the file | |
location ~* \.php$ { | |
deny all; | |
return 404; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment