blob: 0550e7f93ae20f356bebe95720f3ec723f126999 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
## Basic nginx config
[looks promising](https://stackoverflow.com/a/73297125/4415884)
# Basic setup:
# - Maybe change "access_log" to "/var/log/nginx/access.log".
# - For CLI use: Change all "/tmp/nginx" to "." (single dot, aka workdir or
# other user writable dir).
# Public expose setup:
# - Adapt "listen" as commented.
# - set "server_name" to meaningful value.
#
#daemon off; # run in foreground (eg from cli)
events {}
pid /var/run/nginx.pid;
http {
access_log /dev/stdout;
# Directories nginx needs configured to start up.
client_body_temp_path /tmp/nginx;
proxy_temp_path /tmp/nginx;
fastcgi_temp_path /tmp/nginx;
uwsgi_temp_path /tmp/nginx;
scgi_temp_path /tmp/nginx;
server {
# public access: "80" and "[::]:80"
# local access: "127.0.0.1:80" and "[::1]:80"
listen 127.0.0.1:80;
listen [::1]:80;
server_name localhost;
root /srv/www;
location /foo {
#autoindex on; # directory listing
try_files $uri $uri/ =404;
}
location /example {
return 200 "Example says hi";
}
}
}
[tutorial](https://www.javatpoint.com/nginx-minimal-configuration)
## fCGI keep alive backend connections
upstream myFancyBackend {
server unix:/tmp/fastcgi/socket1;
server ;
keepalive 4;
}
server {
location /foo/bar {
fastcgi_pass myFancyBackend;
fastcgi_keep_conn on;
}
}
## Delegate requests to custom scripts via fcgiwrap
true \
&& DOCUMENT_ROOT="/var/www" \
&& CGI_DIR="${DOCUMENT_ROOT:?}/cgi-bin" \
&& VHOST="fcgiwrap" \
&& HOSTNAME="localhost" \
&& LOCATION="/cgi-bin" \
&& NGINX_HTTPD_DIR="/etc/nginx/sites-available" \
&& ENABLE_SITE="ln -s ${NGINX_HTTPD_DIR:?}/${VHOST:?} /etc/nginx/sites-enabled/." \
&& PKGINIT="apt update" \
&& PKGADD="apt install -y --no-install-recommends" \
&& PKGSTOADD="nginx fcgiwrap" \
&& FASTCGI_PARAMS="/etc/nginx/fastcgi_params" \
&& true \
&& ${PKGINIT} \
&& ${PKGADD:?} ${PKGSTOADD:?} \
&& if [ -e "${NGINX_HTTPD_DIR:?}/${VHOST:?}" ]; then \
echo "File already exists: ${NGINX_HTTPD_DIR:?}/${VHOST:?}"; \
false; \
fi; \
&& ( echo 'server {' \
&& echo " listen 80;" \
&& echo " listen [::]:80;" \
&& echo '' \
&& echo " server_name ${HOSTNAME:?};" \
&& echo '' \
&& echo ' location /cgi-bin/ {' \
&& echo ' gzip off;' \
&& echo " root ${DOCUMENT_ROOT:?};" \
&& echo ' fastcgi_pass unix:/var/run/fcgiwrap.socket;' \
&& echo " include ${FASTCGI_PARAMS:?};" \
&& echo ' #fastcgi_param SCRIPT_FILENAME '"${CGI_DIR:?}"'$fastcgi_script_name;' \
&& echo ' }' \
&& echo '' \
&& echo '}' \
) >"${NGINX_HTTPD_DIR:?}/${VHOST:?}" \
&& ${ENABLE_SITE:?} \
&& true
|