Skip to content

Instantly share code, notes, and snippets.

@justintien
Created February 13, 2019 05:19
Show Gist options
  • Save justintien/dc2975e1ed7dc49b9e6e9e973c553124 to your computer and use it in GitHub Desktop.
Save justintien/dc2975e1ed7dc49b9e6e9e973c553124 to your computer and use it in GitHub Desktop.
oschina-config(nginx example)
#### myspace configuration ref: https://gitee.com/oschina/oschina-config/blob/master/main/my.conf ####
server {
listen 80;
server_name my.oschina.net;
include oschina/realip.conf;
if ($request_method !~ ^(GET|POST|HEAD)$ ) {
return 405;
}
include oschina/robot.conf;
location ~ /.svn/ {
return 404;
}
location ~ ^/(WEB-INF)/ {
return 404;
}
location ~ ^/(js|css|img|scripts|stylesheets|uploads)/ {
root /data/oschina/webapp;
access_log off;
expires 30d;
}
location / {
include oschina/deny.conf;
error_page 418 =200 @bots;
if ($is_bot) {
return 418;
}
if ($is_bot2) {
return 418;
}
proxy_pass http://my_backend;
include oschina/proxy.conf;
}
error_page 502 504 /502.html;
error_page 503 /503.html;
error_page 404 /404.html;
error_page 403 /403.html;
}
server {
listen 443 ssl;
server_name my.oschina.net;
include oschina/realip.conf;
ssl on;
ssl_certificate oschina/oschina-bundle.crt;
ssl_certificate_key oschina/oschina.key;
if ($request_method !~ ^(GET|POST|HEAD)$ ) {
return 405;
}
include oschina/robot.conf;
location ~ /.svn/ {
return 404;
}
location ~ ^/(WEB-INF)/ {
return 404;
}
location ~ ^/(js|css|img|scripts|stylesheets|uploads)/ {
root /data/oschina/webapp;
access_log off;
expires 30d;
}
location / {
include oschina/deny.conf;
error_page 418 =200 @bots;
if ($is_bot) {
return 418;
}
if ($is_bot2) {
return 418;
}
proxy_pass http://my_backend;
include oschina/proxy.conf;
}
error_page 502 504 /502.html;
error_page 503 /503.html;
error_page 404 /404.html;
error_page 403 /403.html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment