Last active
February 18, 2022 01:14
-
-
Save pandanote-info/0c45fe148e5b4737a3f6b968ab8bf218 to your computer and use it in GitHub Desktop.
nginxでHTTPS接続のリクエストを受け付けて、GROWIに転送するためのnginxの設定例。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ドル記号の前のバックスラッシュはpanda大学習帳(https://pandanote.info/)での表示用のものです。 | |
# nginxの設定として使用する場合には、ドル記号の前のスラッシュは削除が必要です。 | |
http { | |
(中略) | |
map \$remote_addr \$allowed { | |
~aa.bb.cc. allow; | |
~2aaa:bbbb:cccc:dd: allow; | |
pp.qqq.rr.s allow; | |
127.0.0.1 allow; | |
default deny; | |
} | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name growi.example.com; | |
return 301 https://\$host\$request_uri; | |
root /var/www/wiki; | |
# Load configuration files for the default server block. | |
include /etc/nginx/default.d/*.conf; | |
location / { | |
} | |
error_page 404 /index.php?error=404; | |
location = /40x.html { | |
} | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
} | |
} | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name growi.example.com; | |
root /var/www/wiki; | |
access_log /var/log/nginx/access_wiki.log main; | |
ssl_certificate "/etc/letsencrypt/live/growi.example.com/fullchain.pem"; | |
ssl_certificate_key "/etc/letsencrypt/live/growi.example.com/privkey.pem"; | |
ssl_session_cache shared:SSL:10m; | |
ssl_session_timeout 10m; | |
ssl_protocols TLSv1.3 TLSv1.2; | |
ssl_prefer_server_ciphers on; | |
client_max_body_size 50M; | |
if ($http_user_agent ~ (terminal1|terminal2)) { | |
set $allowed allow; | |
} | |
if ($allowed = deny) { | |
return 404; | |
} | |
location / { | |
proxy_pass http://127.0.0.1:3000/; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
} | |
location /socket.io/ { | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "Upgrade"; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_cache_bypass $http_upgrade; | |
proxy_set_header Host $host; | |
proxy_pass http://127.0.0.1:3000/socket.io/; | |
} | |
index index.html; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment