## Server Block for pingcap.com behind the Ucloud ULB for China Mainland ## TODO: why do we use 301 server { listen 80; server_name www.pingcap.com; return 301 https://pingcap.com$request_uri; } server { listen 80; server_name education.pingcap.com; return 301 https://pingcap.com/zh/education; } server { listen 80; server_name old.pingcap.com; root /var/www/pingcap.com; index index.html index.htm; auth_basic "Ask huohao@pingcap.com for help"; auth_basic_user_file /etc/nginx/htpasswd; autoindex on; } server { listen 80; server_name pingcap.com cn.pingcap.com; root /var/www/pingcap.com-new; index index.html index.htm; access_log /var/log/nginx/pingcap.com.log main; error_log /var/log/nginx/pingcap.com.err error; error_page 404 403 /404.html; ## Ucloud redirect if ($http_x_forwarded_proto = "http") { return 301 https://$server_name$request_uri; } absolute_redirect off; ## https://pingcap.com/tidbslack/ -> https://slack.tidb.io/ location ~ ^/tidbslack(.*)$ { return 302 https://slack.tidb.io/; } location ~ ^/zh/community { return 301 https://tidb.net/; } location ~ ^/zh/htap-summit { return 301 https://en.pingcap.com/htap-summit/; } location ~ ^/community { if ($lang !~ "zh") { return 301 https://en.pingcap.com$request_uri; } return 301 https://tidb.net/; } location ~ ^/event { return 301 https://en.pingcap.com$request_uri; } ## WebAPI location ^~ /api { proxy_pass http://localhost:5000; } location ~ ^/contact-us { if ($lang !~ "zh") { return 301 https://en.pingcap.com/contact-us/; } return 301 https://pingcap.com/zh/contact/; } location / { if ( $lang !~ "zh") { return 301 https://en.pingcap.com$request_uri; } return 301 /zh$request_uri; } # China Mainland Begin rewrite ^/docs-cn(.*)$ https://docs.pingcap.com/docs-cn$1 redirect; rewrite ^/about-cn/recruit(.*) https://job.pingcap.com/ permanent; rewrite ^/recruit-cn(.*) https://job.pingcap.com/ permanent; rewrite ^/about-zh /zh/about-us permanent; rewrite ^/index-zh/?$ /zh/ permanent; rewrite ^/education/?$ /zh/education/ permanent; rewrite ^/about-cn/?$ /zh/about-us/ permanent; rewrite ^/about-cn/news/?$ /zh/about-us/?tab=news permanent; rewrite ^/cases-cn(/?.*)$ /zh/case$1 permanent; rewrite ^/blog-cn(/?.*)$ /zh/blog$1 permanent; rewrite ^/download-cn /zh/product/ permanent; rewrite ^/community-cn/devcon2021/?$ /zh/events/devcon2021 permanent; rewrite ^/community-cn/careers https://tidb-jobs.pingcap.com/ permanent; rewrite ^/community-cn(/?.*) https://tidb.net permanent; rewrite ^/meetup/(.*) https://tidb.io/archived/meetup/$1 permanent; rewrite ^/campaign/tidb-v5.0/ /zh/about-us/company-news-detail/first-to-try-tidb-5.0 permanent; rewrite ^/solutions/intel/? /zh/joint-solution-detail/intel-selected-solution-with-tidb permanent; rewrite ^/licenses/? /zh/licenses/ permanent; location /zh { proxy_pass http://10.9.167.103; } # China Mainland End rewrite ^(/docs/.*)$ https://docs.pingcap.com$1 redirect; rewrite ^/docs/?$ https://docs.pingcap.com/ redirect; location = /index { include access_control/allow_cors.conf; return 301 /en; } location = /index.html { if ( $lang ~ "zh") { return 301 /zh; } include access_control/allow_cors.conf; return 301 en.pingcap.com/index.html; } location ~ ^/products/tidbcloud(.*) { return 301 https://en.pingcap.com/products/tidbcloud$1; } location ~ ^/case-studies(.*) { return 301 https://en.pingcap.com/case-studies$1; } location ~ ^/products/tidb(.*) { return 301 https://en.pingcap.com/products/tidb$1; } location ~ ^/careers(.*) { return 301 https://en.pingcap.com/careers$1; } location ~ ^/trust(.*) { return 301 https://en.pingcap.com/trust$1; } location ~ ^/in-the-news(.*) { return 301 https://en.pingcap.com/in-the-news$1; } location ~ ^/press-releases(.*) { return 301 https://en.pingcap.com/press-releases$1; } ## https://docs.google.com/spreadsheets/d/1rq9adxEo5l_RrzFhr8ztIsYBOg6xu1ANmqQFYg3viIM/edit#gid=0 location ~ ^/success-stories(.*) { return 301 https://en.pingcap.com/case-studies$1; } location ~ ^/blog/(.*) { return 301 https://en.pingcap.com/blog/$1; } location ~ ^/blog$ { return 301 https://en.pingcap.com/blog/$1; } location ~ ^/privacy-policy/archive/(.*) { return 301 https://en.pingcap.com/legal/privacy-policy/archive/$1; } location ~ ^/privacy-policy/archive$ { return 301 https://en.pingcap.com/legal/privacy-policy/archive/$1; } location ~ ^/news/(.*) { return 301 https://en.pingcap.com/in-the-news/$1; } location ~ ^/about/(.*) { return 301 https://en.pingcap.com/about/$1; } location ~ ^/privacy-policy/(.*) { return 301 https://en.pingcap.com/legal/privacy-policy/$1; } location ~ ^/download/(.*) { return 301 https://en.pingcap.com/download/$1; } location ~ ^/partner/aws/(.*) { return 301 https://en.pingcap.com/partner/aws/$1; } location ~ ^/partner/aws(.*) { return 301 https://en.pingcap.com/partner/aws$1; } location ~ ^/tidb-cloud/sign-up { return 301 https://tidbcloud.com/signup; } location ~ ^/tidb-cloud/(.*) { return 301 https://en.pingcap.com/products/tidbcloud/$1; } location ~ ^/en { return 301 https://en.pingcap.com; } location ~ ^/legal { return 301 https://en.pingcap.com/legal; } location ~ ^/legal/(.*) { return 301 https://en.pingcap.com/legal/$1; } location ~ ^/products/tidbcloud/(.*) { return 301 https://en.pingcap.com/products/tidbcloud/$1; } location ~ ^/cookie-policy { return 301 https://en.pingcap.com/cookie-policy; } location /jp { return 301 https://pingcap.co.jp/; } location /jp/blog { return 301 https://pingcap.co.jp/ニュースブログ/; } ## Docs location ~* ^/doc\- { include access_control/allow_cors.conf; if ($request_filename ~ "doc-overview-zh") { rewrite ^(.*)/(.*) $1/docs-cn permanent; } if ($request_filename ~ "doc-overview") { rewrite ^(.*)/(.*) $1/docs permanent; } rewrite ^/doc\-(.*)\-zh(#.*)? /docs-cn/$1 permanent; rewrite ^/doc\-(.*)(#.*)? /docs/$1 permanent; } ## Bloglist location ^~ /bloglist { include access_control/allow_cors.conf; rewrite ^/(bloglist\-zh)(#.*)? /blog-cn permanent; rewrite ^/(bloglist)(#.*)? /blog permanent; } location ^~ /joblist { include access_control/allow_cors.conf; rewrite ^/(joblist\-zh)(#.*)? /recruit-cn permanent; rewrite ^/(joblist)(#.*)? /recruit permanent; } }