Skip to content

Commit a309073

Browse files
committed
Adding Apache server configurations + Django conf templates
1 parent 054c853 commit a309073

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1434
-12
lines changed

Servers/Apache/Readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Apahe2 Server
2+
3+
- Deployment
4+
- Configurations
5+
- Mods
6+
- Security
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## Deploy Django
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## Deploy Node server
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## Deploy Static Websites
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# -----------------------------------------------------------------------
2+
# | Config file for example.com host to deploy django server via apache2 |
3+
# -----------------------------------------------------------------------
4+
# When you use daemon mode, the number of processes and threads is static. This is one of the immediate benefits of using daemon mode.
5+
# Specifically, that process management is more predictable. One of the big problems with using embedded mode is that Apache can decide to create additional processes or kill off existing ones.
6+
# For a web application with large startup costs this is not a good idea as you could suddenly see increased CPU usage due to more processes being started right at the time you don't need it such as when a throughput spike occurs.
7+
# This can actually cause performance to degrade in the short term rather than improve.
8+
9+
#Use Daemon Mode by Restricting WSGIRestrictEmbedded On
10+
WSGIRestrictEmbedded On
11+
12+
<VirtualHost *:80>
13+
14+
ServerName example.com
15+
ServerAlias www.example.com
16+
17+
# Path for Django Project /home/DJANGO_PROJECT/
18+
DocumentRoot /home/DJANGO_PROJECT/
19+
20+
WSGIDaemonProcess DJANGO_PROJECT python-path=/home/DJANGO_PROJECT/:/home/env/lib/python2.7/site-packages
21+
WSGIProcessGroup DJANGO_PROJECT
22+
WSGIScriptAlias / /home/DJANGO_PROJECT/WSGI_RELATIVE_PATH
23+
24+
<Directory $DJANGO_PROJECT_DIR/$DJANGO_PROJECT>
25+
<Files wsgi.py>
26+
Require all granted
27+
</Files>
28+
</Directory>
29+
30+
31+
# Include the basic DevOpsGuide Apache Config set
32+
Include dgac/basic.conf
33+
# Include Required configs from /dgac/
34+
Include dgac/tls/ssl_engine.conf
35+
Include dgac/tls/certificate_files.conf
36+
Include dgac/rewrites/rewrite_nowww.conf
37+
38+
39+
40+
<Directory "/var/www/example.com/public">
41+
Require all granted
42+
</Directory>
43+
44+
</VirtualHost>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# -----------------------------------------------------------------------
2+
# | Config file for example.com host to deploy django server via apache2 |
3+
# -----------------------------------------------------------------------
4+
# When you use daemon mode, the number of processes and threads is static. This is one of the immediate benefits of using daemon mode.
5+
# Specifically, that process management is more predictable. One of the big problems with using embedded mode is that Apache can decide to create additional processes or kill off existing ones.
6+
# For a web application with large startup costs this is not a good idea as you could suddenly see increased CPU usage due to more processes being started right at the time you don't need it such as when a throughput spike occurs.
7+
# This can actually cause performance to degrade in the short term rather than improve.
8+
9+
#Use Daemon Mode by Restricting WSGIRestrictEmbedded On
10+
WSGIRestrictEmbedded On
11+
12+
<VirtualHost *:443>
13+
14+
ServerName example.com
15+
ServerAlias www.example.com
16+
17+
# Path for Django Project /home/DJANGO_PROJECT/
18+
DocumentRoot /home/DJANGO_PROJECT/
19+
20+
WSGIDaemonProcess DJANGO_PROJECT python-path=/home/DJANGO_PROJECT/:/home/env/lib/python2.7/site-packages
21+
WSGIProcessGroup DJANGO_PROJECT
22+
WSGIScriptAlias / /home/DJANGO_PROJECT/WSGI_RELATIVE_PATH
23+
24+
<Directory $DJANGO_PROJECT_DIR/$DJANGO_PROJECT>
25+
<Files wsgi.py>
26+
Require all granted
27+
</Files>
28+
</Directory>
29+
30+
31+
# Include the basic DevOpsGuide Apache Config set
32+
Include dgac/basic.conf
33+
# Include Required configs from /dgac/
34+
Include dgac/tls/ssl_engine.conf
35+
Include dgac/tls/certificate_files.conf
36+
Include dgac/rewrites/rewrite_nowww.conf
37+
38+
39+
40+
<Directory "/var/www/example.com/public">
41+
Require all granted
42+
</Directory>
43+
44+
</VirtualHost>

Servers/Apache/deployment.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Apache2 Server Deployment

Servers/Apache/dgac/basic.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
Include dgac/security/referrer-policy.conf
3+
Include dgac/security/x-content-type-options.conf
4+
Include dgac/security/x-frame-options.conf
5+
Include dgac/cross-origin/images.conf
6+
Include dgac/cross-origin/web_fonts.conf
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# ----------------------------------------------------------------------
2+
# | Cross-origin images |
3+
# ----------------------------------------------------------------------
4+
5+
# Send the CORS header for images when browsers request it.
6+
#
7+
# https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image
8+
# https://blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html
9+
10+
<IfModule mod_setenvif.c>
11+
<IfModule mod_headers.c>
12+
<FilesMatch "\.(avifs?|bmp|cur|gif|ico|jpe?g|jxl|a?png|svgz?|webp)$">
13+
SetEnvIf Origin ":" IS_CORS
14+
Header set Access-Control-Allow-Origin "*" env=IS_CORS
15+
</FilesMatch>
16+
</IfModule>
17+
</IfModule>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# ----------------------------------------------------------------------
2+
# | Cross-origin requests |
3+
# ----------------------------------------------------------------------
4+
5+
# Allow cross-origin requests.
6+
#
7+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
8+
# https://enable-cors.org/
9+
# https://www.w3.org/TR/cors/
10+
11+
# (!) Do not use this without understanding the consequences.
12+
# This will permit access from any other website.
13+
# Instead of using this file, consider using a specific rule such as
14+
# allowing access based on (sub)domain:
15+
#
16+
# Header set Access-Control-Allow-Origin "subdomain.example.com"
17+
#
18+
# (1) When `Access-Control-Allow-Origin` points to a specific rule rather
19+
# than `*`, then `Vary: Origin` should be sent along with the response.
20+
21+
<IfModule mod_headers.c>
22+
Header set Access-Control-Allow-Origin "*"
23+
24+
# (1)
25+
# Header append Vary Origin
26+
</IfModule>

0 commit comments

Comments
 (0)