summaryrefslogtreecommitdiffhomepage
path: root/nginx
diff options
context:
space:
mode:
Diffstat (limited to 'nginx')
-rw-r--r--nginx/.gitignore2
-rw-r--r--nginx/Makefile28
-rw-r--r--nginx/layout/gal.xslt67
-rw-r--r--nginx/layout/simple-gal.xslt36
-rw-r--r--nginx/layout/simple.xslt51
-rw-r--r--nginx/nginx.conf131
-rw-r--r--nginx/passwd/2022.10.111
-rw-r--r--nginx/passwd/houshou1
-rw-r--r--nginx/passwd/japan1
-rw-r--r--nginx/passwd/ntumountainclub1
-rw-r--r--nginx/passwd/rescue1
-rw-r--r--nginx/sites-available/vps354
12 files changed, 674 insertions, 0 deletions
diff --git a/nginx/.gitignore b/nginx/.gitignore
new file mode 100644
index 0000000..c5d401b
--- /dev/null
+++ b/nginx/.gitignore
@@ -0,0 +1,2 @@
1src/
2*tar.gz
diff --git a/nginx/Makefile b/nginx/Makefile
new file mode 100644
index 0000000..cb995f7
--- /dev/null
+++ b/nginx/Makefile
@@ -0,0 +1,28 @@
1.ONESHELL:
2
3VERSION=1.27.2
4
5all: src /home/pham/git/ngx_http_proxy_connect_module
6 cd $<
7 nginx -V |& \
8 sed -nE 's/^configure arguments: ([^\n]*)$$/\1/p' | \
9 sed -nE 's/([^'"'"' \t\n]+('"'"'([^'"'"'\]|\\'"'"'?)*'"'"'|"([^"\\]|\\"?)*")?) ?/\1\n/gp' | \
10 xargs ./configure \
11 --with-http_xslt_module=dynamic \
12 --with-http_dav_module \
13 --with-http_image_filter_module \
14 --add-dynamic-module=/home/pham/git/ngx_http_proxy_connect_module
15 make modules
16 make
17 sudo make install
18 #cd ../.. && rm -rf nginx
19
20src:
21 curl -O https://nginx.org/download/nginx-${VERSION}.tar.gz
22 tar zxvf nginx-${VERSION}.tar.gz && mv nginx-${VERSION} $@
23
24config:
25 ln -sf `pwd`/* /etc/nginx
26
27/home/pham/git/ngx_http_proxy_connect_module:
28 git clone https://github.com/chobits/ngx_http_proxy_connect_module $@
diff --git a/nginx/layout/gal.xslt b/nginx/layout/gal.xslt
new file mode 100644
index 0000000..fadcc37
--- /dev/null
+++ b/nginx/layout/gal.xslt
@@ -0,0 +1,67 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3<xsl:output method="html" encoding="utf-8" indent="yes" />
4<xsl:template match="/">
5<xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html&gt;</xsl:text>
6<html>
7<head>
8 <title><xsl:value-of select="$title" /></title>
9 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" integrity="sha256-Vzbj7sDDS/woiFS3uNKo8eIuni59rjyNGtXfstRzStA=" crossorigin="anonymous"/>
11 <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
12 <script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js" integrity="sha256-yt2kYMy0w8AbtF89WXb2P1rfjcP/HTHLT7097U8Y5b8=" crossorigin="anonymous"></script>
13 <script src="https://cdn.jsdelivr.net/npm/jszip@3.1.5/dist/jszip.min.js" integrity="sha256-PZ/OvdXxEW1u3nuTAUCSjd4lyaoJ3UJpv/X11x2Gi5c=" crossorigin="anonymous"></script>
14 <script src="https://cdn.jsdelivr.net/npm/file-saver@2.0.5/dist/FileSaver.min.js" integrity="sha256-xoh0y6ov0WULfXcLMoaA6nZfszdgI8w2CEJ/3k8NBIE=" crossorigin="anonymous"></script>
15 <style>img { display: block; }</style>
16</head>
17<body>
18<h1 style="text-align: center;"><xsl:value-of select="$title"/></h1>
19<div style="border-bottom: 1px solid gray; margin-bottom: 1rem;"></div>
20<div style="display: flex; flex-wrap: wrap; gap: 2px; justify-content: center;">
21<xsl:for-each select="list/file">
22 <xsl:sort order="descending"/>
23 <a href="{.}" data-fancybox="gallery">
24 <img loading="lazy" src="{.}!lg" height="200"/>
25 </a>
26</xsl:for-each>
27</div>
28<script>
29async function downloadAll() {
30 const zip = JSZip();
31 const folder = zip.folder('<xsl:value-of select="$title" />');
32 const files = [
33 <xsl:for-each select="list/file">
34 <xsl:value-of select="." />
35 </xsl:for-each>
36 ];
37 for(const i in files) {
38 const file = files[i];
39 const resp = await fetch(file);
40 folder.file(file, resp.blob());
41 $.fancybox.animate($.fancybox.getInstance().SlideShow.$progress.show(),{scaleX: i/files.length}, 0.1);
42 }
43 const zipFile = await zip.generateAsync({type: 'blob'});
44 saveAs(zipFile, '<xsl:value-of select="$title" />' + '.zip');
45 $.fancybox.animate($.fancybox.getInstance().SlideShow.$progress.show(),{scaleX: 0}, 0.1);
46}
47
48$('[data-fancybox="gallery"]').fancybox({
49 buttons: [
50 "thumbs",
51 "slideShow",
52 "fullScreen",
53 "downloadAll",
54 "close"
55 ],
56 btnTpl: {
57 downloadAll:
58 '<a class="fancybox-button fancybox-button--download" title="Download All" href="javascript:downloadAll()">' +
59 '<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3M3 17V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z" style="fill:unset; stroke-width:2"/></svg>' +
60 '</a>',
61 }
62});
63</script>
64</body>
65</html>
66</xsl:template>
67</xsl:stylesheet>
diff --git a/nginx/layout/simple-gal.xslt b/nginx/layout/simple-gal.xslt
new file mode 100644
index 0000000..749be72
--- /dev/null
+++ b/nginx/layout/simple-gal.xslt
@@ -0,0 +1,36 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3<xsl:output method="html" encoding="utf-8" indent="yes" />
4<xsl:template match="/">
5<xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html&gt;</xsl:text>
6<html>
7<head>
8 <title><xsl:value-of select="$title" /></title>
9 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10 <style>
11 img {
12 display: inline;
13 width: 23%;
14 margin: 2mm;
15 vertical-align: bottom;
16 }
17 @media all and (max-width: 20.4cm) {
18 img {
19 max-width: calc(100% - 4mm);
20 }
21 }
22 body {
23 margin: 0;
24 }
25 </style>
26</head>
27<body>
28 <xsl:for-each select="list/file">
29 <a href="{.}" title="click to enlarge">
30 <img src="{.}" alt="{.}"/>
31 </a>
32 </xsl:for-each>
33</body>
34</html>
35</xsl:template>
36</xsl:stylesheet>
diff --git a/nginx/layout/simple.xslt b/nginx/layout/simple.xslt
new file mode 100644
index 0000000..9cc5ad6
--- /dev/null
+++ b/nginx/layout/simple.xslt
@@ -0,0 +1,51 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3 <xsl:template match="/">
4 <html>
5 <body style="margin: 0 auto; max-width: 900px; width: fit-content;">
6
7 <h3><xsl:value-of select="name(//directory)"/></h3>
8
9 <table border="0">
10 <tr bgcolor="#7DAFFF">
11 <th>Name</th>
12 <th style="padding-inline: 2em;">Size</th>
13 <th>Date</th>
14 </tr>
15 <xsl:for-each select="list/*">
16 <xsl:sort select="mtime" />
17
18 <xsl:variable name="name">
19 <xsl:value-of select="."/>
20 </xsl:variable>
21
22 <xsl:variable name="size">
23 <xsl:if test="string-length(@size) &gt; 0">
24 <xsl:if test="number(@size) &gt; 0">
25 <xsl:choose>
26 <xsl:when test="round(@size div 1024) &lt; 1"><xsl:value-of select="@size" /></xsl:when>
27 <xsl:when test="round(@size div 1048576) &lt; 1"><xsl:value-of select="format-number((@size div 1024), '0.0')" />K</xsl:when>
28 <xsl:otherwise><xsl:value-of select="format-number((@size div 1048576), '0.00')" /> MB</xsl:otherwise>
29 </xsl:choose>
30 </xsl:if>
31 </xsl:if>
32 </xsl:variable>
33
34 <xsl:variable name="date">
35 <xsl:value-of select="substring(@mtime,6,2)"/>/<xsl:value-of select="substring(@mtime,9,2)"/><xsl:text> </xsl:text>
36 <xsl:value-of select="substring(@mtime,12,2)"/>:<xsl:value-of select="substring(@mtime,15,2)"/>:<xsl:value-of select="substring(@mtime,18,2)"/><xsl:text> </xsl:text>
37 <xsl:value-of select="substring(@mtime,1,4)"/>
38 </xsl:variable>
39
40 <tr>
41 <td><a href="{$name}"><xsl:value-of select="."/></a></td>
42 <td align="right" style="padding-right: 2em;"><xsl:value-of select="$size"/></td>
43 <td><xsl:value-of select="$date"/></td>
44 </tr>
45
46 </xsl:for-each>
47 </table>
48 </body>
49 </html>
50 </xsl:template>
51</xsl:stylesheet>
diff --git a/nginx/nginx.conf b/nginx/nginx.conf
new file mode 100644
index 0000000..d0601ec
--- /dev/null
+++ b/nginx/nginx.conf
@@ -0,0 +1,131 @@
1load_module /etc/nginx/modules/ngx_http_dav_ext_module.so;
2load_module /etc/nginx/modules/ngx_http_xslt_filter_module.so;
3load_module /etc/nginx/modules/ngx_http_proxy_connect_module.so;
4
5user pham;
6worker_processes 1;
7
8#error_log logs/error.log;
9#error_log logs/error.log notice;
10#error_log logs/error.log info;
11
12#pid logs/nginx.pid;
13
14
15events {
16 worker_connections 1024;
17}
18
19
20http {
21 types_hash_max_size 4096;
22 server_names_hash_bucket_size 128;
23
24 include mime.types;
25 default_type application/octet-stream;
26 disable_symlinks off;
27
28 # Read manual for valid variables:
29 # https://nginx.org/en/docs/http/ngx_http_core_module.html#variables
30
31 #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
32 # '$status $body_bytes_sent "$http_referer" '
33 # '"$http_user_agent" "$http_x_forwarded_for"';
34 log_format main '$status $request_method\t$http_host$uri\tfrom $http_referer\n'
35 '$time_iso8601 $remote_addr\r\t\t\t\t\t $http_user_agent';
36 access_log /var/log/nginx/access.log main;
37
38 sendfile on;
39 #tcp_nopush on;
40
41 #keepalive_timeout 0;
42 keepalive_timeout 65;
43
44 #gzip on;
45
46 #server {
47 # listen 80;
48 # server_name localhost;
49
50 # #charset koi8-r;
51
52 # #access_log logs/host.access.log main;
53
54 # location / {
55 # root /usr/share/nginx/html;
56 # index index.html index.htm;
57 # }
58
59 # #error_page 404 /404.html;
60
61 # # redirect server error pages to the static page /50x.html
62 # #
63 # error_page 500 502 503 504 /50x.html;
64 # location = /50x.html {
65 # root /usr/share/nginx/html;
66 # }
67
68 # proxy the PHP scripts to Apache listening on 127.0.0.1:80
69 #
70 #location ~ \.php$ {
71 # proxy_pass http://127.0.0.1;
72 #}
73
74 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
75 #
76 #location ~ \.php$ {
77 # root html;
78 # fastcgi_pass 127.0.0.1:9000;
79 # fastcgi_index index.php;
80 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
81 # include fastcgi_params;
82 #}
83
84 # deny access to .htaccess files, if Apache's document root
85 # concurs with nginx's one
86 #
87 #location ~ /\.ht {
88 # deny all;
89 #}
90 #}
91
92
93 # another virtual host using mix of IP-, name-, and port-based configuration
94 #
95 #server {
96 # listen 8000;
97 # listen somename:8080;
98 # server_name somename alias another.alias;
99
100 # location / {
101 # root html;
102 # index index.html index.htm;
103 # }
104 #}
105
106
107 # HTTPS server
108 #
109 #server {
110 # listen 443 ssl;
111 # server_name localhost;
112
113 # ssl_certificate cert.pem;
114 # ssl_certificate_key cert.key;
115
116 # ssl_session_cache shared:SSL:1m;
117 # ssl_session_timeout 5m;
118
119 # ssl_ciphers HIGH:!aNULL:!MD5;
120 # ssl_prefer_server_ciphers on;
121
122 # location / {
123 # root html;
124 # index index.html index.htm;
125 # }
126 #}
127
128 # load configs
129 #include /etc/nginx/conf.d/*.conf;
130 include /etc/nginx/sites-enabled/vps;
131}
diff --git a/nginx/passwd/2022.10.11 b/nginx/passwd/2022.10.11
new file mode 100644
index 0000000..7037748
--- /dev/null
+++ b/nginx/passwd/2022.10.11
@@ -0,0 +1 @@
lay911225:$apr1$yc365c.t$HrUOy9eWekr6xNkWsTZBR.
diff --git a/nginx/passwd/houshou b/nginx/passwd/houshou
new file mode 100644
index 0000000..7ec2d1d
--- /dev/null
+++ b/nginx/passwd/houshou
@@ -0,0 +1 @@
houshou:$apr1$tSspURxF$zciiExFt0nj0n.pbJiXUh0
diff --git a/nginx/passwd/japan b/nginx/passwd/japan
new file mode 100644
index 0000000..da8a465
--- /dev/null
+++ b/nginx/passwd/japan
@@ -0,0 +1 @@
klara:$apr1$ZCAf5ib0$ZjDi7s1djpikGXhRQaQX01
diff --git a/nginx/passwd/ntumountainclub b/nginx/passwd/ntumountainclub
new file mode 100644
index 0000000..d485239
--- /dev/null
+++ b/nginx/passwd/ntumountainclub
@@ -0,0 +1 @@
radio:$apr1$rexQL6MJ$MRLWfUmi4FyeJ65oKYz/Q/
diff --git a/nginx/passwd/rescue b/nginx/passwd/rescue
new file mode 100644
index 0000000..d46bf6f
--- /dev/null
+++ b/nginx/passwd/rescue
@@ -0,0 +1 @@
mountainclub:$apr1$H5RdWRmY$Clj3PkR.x4vLomKNK/ZN3.
diff --git a/nginx/sites-available/vps b/nginx/sites-available/vps
new file mode 100644
index 0000000..bad4621
--- /dev/null
+++ b/nginx/sites-available/vps
@@ -0,0 +1,354 @@
1#map $token $api_client_name {
2# default "";
3#
4# # CAUTION!! Change token and client name wisely
5# "XXXX" "client";
6#}
7
8# Gets the basename of the original request
9map $request_uri $request_basename {
10 ~/(?<captured_request_basename>[^/?]*)(?:\?|$) $captured_request_basename;
11}
12
13# Gets the basename of the current uri
14map $uri $basename {
15 ~/(?<captured_basename>[^/]*)$ $captured_basename;
16}
17
18server {
19 server_name topo.tw www.topo.tw;
20
21 listen 80;
22 listen 443 ssl;
23 ssl_certificate /etc/nginx/ssl/fullchain.cert;
24 ssl_certificate_key /etc/nginx/ssl/cert.pem;
25
26 root /srv/http;
27 index index.html;
28 autoindex on;
29 autoindex_exact_size off;
30
31 # charset
32 charset utf-8;
33 charset_types *;
34 override_charset on;
35 default_type "text/plain; charset=utf-8";
36
37 # header
38 proxy_set_header Host $host;
39 add_header Cache-Control "no-cache" always;
40 #add_header Cache-Control "max-age=604800";
41 error_page 404 /404.html;
42 error_log /var/log/nginx/error.log debug;
43 #rewrite_log on;
44
45 location ~ \.html$ {
46 try_files $uri =404;
47 }
48
49 location ~ \.js$ {
50 add_header Access-Control-Allow-Origin *;
51 }
52
53 location ~ [^/]$ {
54 try_files $uri @rewrite_no_slash;
55 }
56
57 location @rewrite_no_slash {
58 add_header rewrite no_slash;
59 rewrite ^(.+)$ $1.html permanent;
60 }
61
62 location ~ /$ {
63 try_files $uri @rewrite_slash;
64 }
65
66 location @rewrite_slash {
67 rewrite ^(.+)/$ $1.html permanent;
68 }
69
70 rewrite ^/posts$ /posts/ permanent;
71 location = /posts/ {
72 autoindex_format xml;
73 xslt_string_param title "/posts/";
74 xslt_stylesheet layout/simple.xslt;
75 add_header Cache-Control "no-cache" always;
76 }
77
78 # This configuration allow you to upload/modify/delete file, for example:
79 # curl -X PUT -F file=@foo https://topo.tw/doc/bar
80 location ^~ /doc {
81 alias /home/pham/doc/;
82
83 client_body_temp_path /tmp/client_temp;
84 dav_methods PUT DELETE MKCOL COPY MOVE;
85 create_full_put_path on;
86 dav_access group:rw all:r;
87 client_max_body_size 10000m;
88 }
89
90 location ^~ /photos/ {
91 alias /home/pham/data/s3.photos/;
92 autoindex_format xml;
93 xslt_string_param title "photos";
94 xslt_stylesheet layout/gal.xslt;
95 try_files $uri $uri/ =404;
96 expires max;
97
98 if ($uri ~ ^/photos/([^!]+)!(large|lg|md)$ ) {
99 set $filename /home/pham/data/s3.photos/$1;
100 set $img_version $2;
101 rewrite ^ /thumbnail;
102 }
103 }
104
105 rewrite ^/p(ublic)?$ /public/ permanent;
106 rewrite ^/p/(.*)$ /public/$1;
107 location ^~ /public/ {
108 alias /home/pham/public/;
109 autoindex_format xml;
110 xslt_string_param title "/posts/";
111 xslt_stylesheet layout/simple.xslt;
112 add_header Access-Control-Allow-Origin "*" always;
113 add_header Cache-Control "no-cache" always;
114 }
115
116 # thumbnail CGI, requires variables 'filename' and 'img_version'
117 location = /thumbnail {
118 # Prepare the required parameters (width, height, cropping or zooming) according to the URL address!
119 set $img_type resize;
120 set $img_w -;
121 set $img_h -;
122 if ($img_version = 'large') {
123 set $img_type resize;
124 set $img_w 1920;
125 }
126 if ($img_version = 'lg') {
127 set $img_type crop;
128 set $img_w 256;
129 set $img_h 256;
130 }
131 if ($img_version = 'md') {
132 set $img_type crop;
133 set $img_w 128;
134 set $img_h 128;
135 }
136 rewrite ^ /_$img_type;
137 }
138
139 # Processing of Scaled Pictures
140 location = /_resize {
141 alias $filename;
142 image_filter resize $img_w $img_h;
143 image_filter_jpeg_quality 95;
144 image_filter_buffer 20M;
145 image_filter_interlace on;
146 }
147
148 # Processing of clipped pictures
149 location = /_crop {
150 alias $filename;
151 image_filter crop $img_w $img_h;
152 image_filter_jpeg_quality 95;
153 image_filter_buffer 20M;
154 image_filter_interlace on;
155 }
156
157 location ^~ /wallpapers {
158 alias /home/pham/public/wallpapers/;
159
160 autoindex_format xml;
161 xslt_string_param title "Wallpaper Collection!";
162 xslt_stylesheet layout/gal.xslt;
163 try_files $uri $uri/ =404;
164
165 if ($uri ~ ([^/!]+)!(large|lg|md)$ ) {
166 set $filename /home/pham/public/wallpapers/$1;
167 set $img_version $2;
168 rewrite ^ /thumbnail;
169 }
170 }
171
172 location ^~ /tmp {
173 alias /home/pham/public/tmp/;
174 autoindex on;
175 add_header "Content-Type" "text/plain; charset=utf-8";
176 }
177
178 location ^~ /osm {
179 alias /home/pham/public/osm/;
180 autoindex on;
181 }
182
183 location ^~ /tainan/ {
184 alias /home/pham/public/tainan/;
185 autoindex on;
186 index =404;
187 }
188
189 location /public/layx {
190 alias /home/pham/public/layx/;
191
192 autoindex on;
193
194 auth_basic "You need to login";
195 auth_basic_user_file /etc/nginx/passwd/2022.10.11;
196 }
197
198 location ^~ /private/ {
199 alias /home/pham/private/;
200 autoindex on;
201 auth_basic "You need to login";
202 auth_basic_user_file /etc/nginx/passwd/japan;
203 }
204
205 location = /japan.html {
206 autoindex on;
207
208 auth_basic "You need to login";
209 auth_basic_user_file /etc/nginx/passwd/japan;
210 }
211
212 location ^~ /houshou {
213 alias /home/pham/houshou/;
214
215 autoindex on;
216 autoindex_format xml;
217 xslt_string_param title "Houshou Collection!";
218 xslt_stylesheet layout/gal.xslt;
219 try_files $uri $uri/ =404;
220
221 auth_basic "You need to login";
222 auth_basic_user_file /etc/nginx/passwd/houshou;
223
224 if ($uri ~ ([^/!]+)!(large|lg|md)$ ) {
225 set $filename /home/pham/houshou/$1;
226 set $img_version $2;
227 rewrite ^ /thumbnail;
228 }
229 }
230
231 location ^~ /houshou2 {
232 alias /home/pham/houshou2/;
233
234 autoindex on;
235 autoindex_format xml;
236 xslt_string_param title "Houshou Collection!";
237 #xslt_stylesheet layout/simple-gal.xslt;
238 xslt_stylesheet layout/gal.xslt;
239 try_files $uri $uri/ =404;
240
241 if ($uri ~ ([^/!]+)!(large|lg|md)$ ) {
242 set $filename /home/pham/houshou2/$1;
243 set $img_version $2;
244 rewrite ^ /thumbnail;
245 }
246 }
247
248 location /rescue {
249 root /home/pham;
250
251 auth_basic "You need to login";
252 auth_basic_user_file /etc/nginx/passwd/rescue;
253 }
254
255# location /upload/ {
256# proxy_pass http://127.0.0.1:8000/;
257# }
258
259 #rewrite ^/up$ /up/;
260 #location /up/ {
261 # proxy_set_header X-Forwarded-Proto https;
262 # proxy_set_header Referer $host/up/;
263 # proxy_pass http://127.0.0.1:8080/;
264
265 # client_max_body_size 1g;
266 #}
267
268 #location = /_validate_token {
269 # internal;
270
271 # if ($token = "") {
272 # return 401; # Unauthorized
273 # }
274
275 # if ($api_client_name = "") {
276 # return 403; # Forbidden
277 # }
278
279 # return 204; # OK (no content)
280 #}
281
282}
283
284# git server
285server {
286 server_name git.topo.tw;
287
288 listen 80;
289 listen 443 ssl;
290 ssl_certificate /etc/nginx/ssl/git.topo.tw/fullchain.cer;
291 ssl_certificate_key /etc/nginx/ssl/git.topo.tw/git.topo.tw.key;
292
293 root /srv/git/www;
294
295 location ~ (/.*) {
296 #include fastcgi_params;
297 #fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
298 ## export all repositories under GIT_PROJECT_ROOT
299 #fastcgi_param GIT_HTTP_EXPORT_ALL "";
300 #fastcgi_param GIT_PROJECT_ROOT /srv/git;
301 #fastcgi_param PATH_INFO $1;
302 }
303}
304
305# Block all direct accesses via IP address
306server {
307 server_name "~[\d\.]+";
308 listen 80;
309 listen 443 ssl;
310
311 error_page 404 /404.html;
312 return 404;
313}
314
315## Redirect 80 to 443
316#server {
317# if ($host = topo.tw) {
318# return 301 https://$host$request_uri;
319# } # managed by Certbot
320#
321#
322# #listen 80;
323# server_name topo.tw;
324# return 301 https://$host$request_uri;
325#
326#
327#}
328
329## Forward Proxy
330#server {
331# resolver 8.8.8.8;
332# listen 13288;
333#
334# proxy_connect;
335# proxy_connect_allow 443 563;
336# proxy_connect_connect_timeout 10s;
337# proxy_connect_read_timeout 10s;
338# proxy_connect_send_timeout 10s;
339# location / {
340# proxy_pass http://$host;
341# proxy_set_header Host $host;
342# }
343#}
344
345#server {
346# server_name demo.topo.tw;
347# root /;
348#
349# location / {
350# index /home/pham/git/vps/demo/client.sh;
351# add_header Content-Type text/plain;
352# }
353# #listen 80;
354#}