Skip to content

Commit effa1c3

Browse files
committed
switch from apache to nginx
1 parent 3d837ee commit effa1c3

File tree

3 files changed

+170
-8
lines changed

3 files changed

+170
-8
lines changed

multiple-servers/IMPLEMENTATION.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,12 @@ Copied over from server-database, with file split up:
5151

5252
This has the same setup steps as server-database, so those can be copied over.
5353

54-
## Apache
54+
## Nginx
5555

56-
Switch static server over to 8083.
56+
Switch static server over to 8082.
5757

58-
`brew install apache2` (or `brew install httpd`?)
58+
`brew install nginx`
5959

6060
```
61-
brew services restart httpd
62-
```
63-
64-
```
65-
sudo httpd -D FOREGROUND -f `pwd`/config/httpd.conf
61+
nginx -c `pwd`/config/nginx.conf
6662
```

multiple-servers/config/mime.types

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
2+
types {
3+
text/html html htm shtml;
4+
text/css css;
5+
text/xml xml;
6+
image/gif gif;
7+
image/jpeg jpeg jpg;
8+
application/javascript js;
9+
application/atom+xml atom;
10+
application/rss+xml rss;
11+
12+
text/mathml mml;
13+
text/plain txt;
14+
text/vnd.sun.j2me.app-descriptor jad;
15+
text/vnd.wap.wml wml;
16+
text/x-component htc;
17+
18+
image/avif avif;
19+
image/png png;
20+
image/svg+xml svg svgz;
21+
image/tiff tif tiff;
22+
image/vnd.wap.wbmp wbmp;
23+
image/webp webp;
24+
image/x-icon ico;
25+
image/x-jng jng;
26+
image/x-ms-bmp bmp;
27+
28+
font/woff woff;
29+
font/woff2 woff2;
30+
31+
application/java-archive jar war ear;
32+
application/json json;
33+
application/mac-binhex40 hqx;
34+
application/msword doc;
35+
application/pdf pdf;
36+
application/postscript ps eps ai;
37+
application/rtf rtf;
38+
application/vnd.apple.mpegurl m3u8;
39+
application/vnd.google-earth.kml+xml kml;
40+
application/vnd.google-earth.kmz kmz;
41+
application/vnd.ms-excel xls;
42+
application/vnd.ms-fontobject eot;
43+
application/vnd.ms-powerpoint ppt;
44+
application/vnd.oasis.opendocument.graphics odg;
45+
application/vnd.oasis.opendocument.presentation odp;
46+
application/vnd.oasis.opendocument.spreadsheet ods;
47+
application/vnd.oasis.opendocument.text odt;
48+
application/vnd.openxmlformats-officedocument.presentationml.presentation
49+
pptx;
50+
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
51+
xlsx;
52+
application/vnd.openxmlformats-officedocument.wordprocessingml.document
53+
docx;
54+
application/vnd.wap.wmlc wmlc;
55+
application/wasm wasm;
56+
application/x-7z-compressed 7z;
57+
application/x-cocoa cco;
58+
application/x-java-archive-diff jardiff;
59+
application/x-java-jnlp-file jnlp;
60+
application/x-makeself run;
61+
application/x-perl pl pm;
62+
application/x-pilot prc pdb;
63+
application/x-rar-compressed rar;
64+
application/x-redhat-package-manager rpm;
65+
application/x-sea sea;
66+
application/x-shockwave-flash swf;
67+
application/x-stuffit sit;
68+
application/x-tcl tcl tk;
69+
application/x-x509-ca-cert der pem crt;
70+
application/x-xpinstall xpi;
71+
application/xhtml+xml xhtml;
72+
application/xspf+xml xspf;
73+
application/zip zip;
74+
75+
application/octet-stream bin exe dll;
76+
application/octet-stream deb;
77+
application/octet-stream dmg;
78+
application/octet-stream iso img;
79+
application/octet-stream msi msp msm;
80+
81+
audio/midi mid midi kar;
82+
audio/mpeg mp3;
83+
audio/ogg ogg;
84+
audio/x-m4a m4a;
85+
audio/x-realaudio ra;
86+
87+
video/3gpp 3gpp 3gp;
88+
video/mp2t ts;
89+
video/mp4 mp4;
90+
video/mpeg mpeg mpg;
91+
video/quicktime mov;
92+
video/webm webm;
93+
video/x-flv flv;
94+
video/x-m4v m4v;
95+
video/x-mng mng;
96+
video/x-ms-asf asx asf;
97+
video/x-ms-wmv wmv;
98+
video/x-msvideo avi;
99+
}

multiple-servers/config/nginx.conf

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Determines whether nginx should become a daemon (run in the background — daemon – or foreground)
2+
# https://nginx.org/en/docs/ngx_core_module.html#daemon
3+
daemon off;
4+
5+
# For development purposes, log to stderr
6+
# https://nginx.org/en/docs/ngx_core_module.html#error_log
7+
error_log stderr info;
8+
9+
# Defines the number of worker processes. Auto tries to optimise this, likely to the number of CPU cores.
10+
# https://nginx.org/en/docs/ngx_core_module.html#worker_processes
11+
worker_processes auto;
12+
13+
# Directives that affect connection processing.
14+
# https://nginx.org/en/docs/ngx_core_module.html#events
15+
events {
16+
# Sets the maximum number of simultaneous connections that can be opened by a worker process.
17+
# https://nginx.org/en/docs/ngx_core_module.html#events
18+
worker_connections 1024;
19+
}
20+
21+
http {
22+
include mime.types;
23+
24+
# Defines the default MIME type of a response.
25+
# https://nginx.org/en/docs/http/ngx_http_core_module.html#default_type
26+
default_type text/plain;
27+
28+
# Log to stdout
29+
# https://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
30+
access_log /dev/stdout;
31+
32+
# Specifies log format.
33+
# https://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
34+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
35+
'$status $body_bytes_sent "$http_referer" '
36+
'"$http_user_agent" "$http_x_forwarded_for"';
37+
38+
# By default, NGINX handles file transmission itself and copies the file into the buffer before sending it.
39+
# Enabling the sendfile directive eliminates the step of copying the data into the buffer and enables direct
40+
# copying data from one file descriptor to another.
41+
# https://docs.nginx.com/nginx/admin-guide/web-server/serving-static-content/
42+
sendfile on;
43+
44+
# Enable compression
45+
# https://docs.nginx.com/nginx/admin-guide/web-server/compression/
46+
gzip on;
47+
48+
# Sets configuration for a virtual server.
49+
# https://nginx.org/en/docs/http/ngx_http_core_module.html#server
50+
server {
51+
# Port to listen on
52+
listen 8080;
53+
54+
# Requests to /api/ are forwarded to a local server running on port 8081
55+
# https://nginx.org/en/docs/http/ngx_http_core_module.html#location
56+
location /api/ {
57+
# Set URL to which the request is passed.
58+
# https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass
59+
proxy_pass http://0.0.0.0:8081/;
60+
}
61+
62+
# Other request forwarded to a local server running on port 8082
63+
location / {
64+
proxy_pass http://0.0.0.0:8082/;
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)