Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx docker temp #700

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile.nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM nginx
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,21 @@ services:
- "127.0.0.1:5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
nginx:
build:
context: .
dockerfile: Dockerfile.nginx
depends_on:
- app
ports:
- "127.0.0.1:8080:80"
volumes:
- ./nginx/:/etc/nginx/

volumes:
elasticsearch-data:
driver: local
postgres-data:
driver: local
nginx-data:
driver: local
18 changes: 18 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>

<article>
<h1>We&rsquo;ll be back soon!</h1>
<div>
<p>Sorry for the inconvenience but we&rsquo;re performing some maintenance at the moment. If you need to you can always <a href="mailto:[email protected]">contact us</a>, otherwise we&rsquo;ll be back online shortly!</p>
<p>&mdash; The Safecast Team</p>
</div>
</article>
47 changes: 47 additions & 0 deletions nginx/conf.d/1_webapp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#Modified from: https://itnext.io/docker-rails-puma-nginx-postgres-999cd8866b18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About the filename: files are sorted in lexical order, not numeric order, so this will not behave the way that you think it will.

01_file
02_file
09_file
10_file
1_file
11_file
50_file
99_file

The convention is to use two digits, and if the ordering doesn't matter, use 50_ to put it in the middle.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the other files aren't following the normal convention, so I guess it doesn't matter that much. 1_ will sort before anything that begins with a letter of the alphabet.


upstream safecastapi {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would appreciate it if you could leave a comment on this pull request to describe where you made changes and what changes you made.

server app:3000;
}

limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good start, but, if it is possible, it would be best if we could add this configuration to a new file instead of modifying an existing one.


server{
server_name safecastapi;
# define the public application root
root /var/www/safecastapi/public;
index index.html;
# deny requests for files that should never be accessed
location ~ /\. {
deny all;
}
location ~* ^.+\.(rb|log)$ {
deny all;
}

# serve static (compiled) assets directly if they exist (for rails production)
location ~ ^/(assets|images|javascripts|stylesheets|swfs|system)/ {
try_files $uri @rails;
access_log off;
gzip_static on;
# to serve pre-gzipped version
expires max;
add_header Cache-Control public;

add_header Last-Modified "";
add_header ETag "";
break;
}

location / {
limit_req zone=one;
try_files $uri @rails;
}
location @rails {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://safecastapi;
}
}
1 change: 1 addition & 0 deletions nginx/conf.d/blockips.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#deny 192.168.176.1;
5 changes: 5 additions & 0 deletions nginx/conf.d/maintenance.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
server {
listen 81;
server_name _ localhost;
root /var/app/current/public/maintenance;
}
5 changes: 5 additions & 0 deletions nginx/conf.d/maintenance.conf.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
server {
listen 81;
server_name _ localhost;
root /var/app/current/public/maintenance;
}
1 change: 1 addition & 0 deletions nginx/conf.d/proxy.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
client_max_body_size 10M;
1 change: 1 addition & 0 deletions nginx/conf.d/proxy.conf.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
client_max_body_size 10M;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can delete the .bak files to reduce the distraction.

1 change: 1 addition & 0 deletions nginx/conf.d/rate_limit.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's supposed to be here?

15 changes: 15 additions & 0 deletions nginx/conf.d/virtual.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# A virtual host using mix of IP-, name-, and port-based configuration
#

#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}

1 change: 1 addition & 0 deletions nginx/conf.d/web.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
proxy_read_timeout 600s;
26 changes: 26 additions & 0 deletions nginx/fastcgi.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
26 changes: 26 additions & 0 deletions nginx/fastcgi.conf.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
25 changes: 25 additions & 0 deletions nginx/fastcgi_params
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
25 changes: 25 additions & 0 deletions nginx/fastcgi_params.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
9 changes: 9 additions & 0 deletions nginx/html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<html>
<head>
<title>This is the title of the webpage!</title>
</head>
<body>
<p>This is an example paragraph. Anything in the <strong>body</strong> tag will appear on the page, just like this <strong>p</strong> tag and its contents.</p>
</body>
</html>
109 changes: 109 additions & 0 deletions nginx/koi-utf
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@

# This map is not a full koi8-r <> utf8 map: it does not contain
# box-drawing and some other characters. Besides this map contains
# several koi8-u and Byelorussian letters which are not in koi8-r.
# If you need a full and standard map, use contrib/unicode2nginx/koi-utf
# map instead.

charset_map koi8-r utf-8 {

80 E282AC ; # euro

95 E280A2 ; # bullet

9A C2A0 ; # &nbsp;

9E C2B7 ; # &middot;

A3 D191 ; # small yo
A4 D194 ; # small Ukrainian ye

A6 D196 ; # small Ukrainian i
A7 D197 ; # small Ukrainian yi

AD D291 ; # small Ukrainian soft g
AE D19E ; # small Byelorussian short u

B0 C2B0 ; # &deg;

B3 D081 ; # capital YO
B4 D084 ; # capital Ukrainian YE

B6 D086 ; # capital Ukrainian I
B7 D087 ; # capital Ukrainian YI

B9 E28496 ; # numero sign

BD D290 ; # capital Ukrainian soft G
BE D18E ; # capital Byelorussian short U

BF C2A9 ; # (C)

C0 D18E ; # small yu
C1 D0B0 ; # small a
C2 D0B1 ; # small b
C3 D186 ; # small ts
C4 D0B4 ; # small d
C5 D0B5 ; # small ye
C6 D184 ; # small f
C7 D0B3 ; # small g
C8 D185 ; # small kh
C9 D0B8 ; # small i
CA D0B9 ; # small j
CB D0BA ; # small k
CC D0BB ; # small l
CD D0BC ; # small m
CE D0BD ; # small n
CF D0BE ; # small o

D0 D0BF ; # small p
D1 D18F ; # small ya
D2 D180 ; # small r
D3 D181 ; # small s
D4 D182 ; # small t
D5 D183 ; # small u
D6 D0B6 ; # small zh
D7 D0B2 ; # small v
D8 D18C ; # small soft sign
D9 D18B ; # small y
DA D0B7 ; # small z
DB D188 ; # small sh
DC D18D ; # small e
DD D189 ; # small shch
DE D187 ; # small ch
DF D18A ; # small hard sign

E0 D0AE ; # capital YU
E1 D090 ; # capital A
E2 D091 ; # capital B
E3 D0A6 ; # capital TS
E4 D094 ; # capital D
E5 D095 ; # capital YE
E6 D0A4 ; # capital F
E7 D093 ; # capital G
E8 D0A5 ; # capital KH
E9 D098 ; # capital I
EA D099 ; # capital J
EB D09A ; # capital K
EC D09B ; # capital L
ED D09C ; # capital M
EE D09D ; # capital N
EF D09E ; # capital O

F0 D09F ; # capital P
F1 D0AF ; # capital YA
F2 D0A0 ; # capital R
F3 D0A1 ; # capital S
F4 D0A2 ; # capital T
F5 D0A3 ; # capital U
F6 D096 ; # capital ZH
F7 D092 ; # capital V
F8 D0AC ; # capital soft sign
F9 D0AB ; # capital Y
FA D097 ; # capital Z
FB D0A8 ; # capital SH
FC D0AD ; # capital E
FD D0A9 ; # capital SHCH
FE D0A7 ; # capital CH
FF D0AA ; # capital hard sign
}
Loading