## Server Block for pingcap.com-new behind the Ucloud ULB map $http_accept_language $lang_new { default "en"; "~^zh" "zh"; "~ja" "ja"; } map $status $expires { default off; ~301 7d; } server { listen 80; server_name www.pingcap.com; return 301 https://pingcap.com$request_uri; } server { listen 80; server_name pingcap.com; #root /var/www/pingcap.com-new; index index.html index.htm; error_page 404 403 /404.html; expires $expires; access_log /var/log/nginx/pingcap.com.log main; error_log /var/log/nginx/pingcap.com.err error; ## 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/; } ## WebAPI location ^~ /api { proxy_pass http://localhost:5000; } location /weekly { root /var/www/pingcap.com; } 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 ^/download-cn/community/?$ /zh/product-community/ permanent; rewrite ^/community-cn/devcon2021/?$ /zh/events/devcon2021 permanent; rewrite ^/community-cn/careers https://tidb-jobs.pingcap.com/ permanent; rewrite ^/community-cn(/?.*) https://tidb.io/archived/events/$1 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_set_header Host $host; proxy_pass https://117.50.106.178; } location ~ ^/tidb-cloud(.*)? { return 302 https://$server_name/products/tidbcloud/; } location ~ ^/news/ { return 302 https://$server_name/in-the-news/; } # location ~ ^/(community-cn|blog-cn|about-cn|cases-cn|download-cn|solutions|tidb-planet|licenses|news|tidb-academy|campaign\/tidb-v5.0|zh\/privacy-policy-archive|terms-of-service|meetup|community\/organization|community\/devcon2020|community\/tidb-usability-challenge|tidbslack|community\/developer-group|community\/events\/hackathon2020) { # root /var/www/pingcap.com; # } location ~ ^/(terms-of-service|tidb-academy|weekly|community/(events/)?(devcon2020|tidb-usability-challenge|hackathon2020)) { root /var/www/pingcap.com; } rewrite /docs-cn(.*)$ https://docs.pingcap.com/docs-cn$1 redirect; rewrite ^(/docs/.*)$ https://docs.pingcap.com$1 redirect; rewrite ^/docs/?$ https://docs.pingcap.com/ redirect; rewrite /success-stories(.*)$ /case-studies$1 redirect; rewrite ^/en(.*)$ / redirect; location /jp { return 301 https://pingcap.co.jp; } location /jp/blog { return 301 https://pingcap.co.jp/ニュースブログ/; } location /pingcap-successfully-completes-type-1-soc-2-examination-for-tidb-cloud { return 301 https://en.pingcap.com/press-release/pingcap-successfully-completes-soc-2-type-1-examination-for-tidb-cloud/; } location /pingcap-the-company-behind-tidb-raises-270-million-in-series-d-funding { return 301 https://en.pingcap.com/press-release/pingcap-the-company-behind-tidb-raises-270-million-in-series-d-funding/; } location ~ ^/contact-us/(.*) { if ($lang_new ~ "ja") { return 301 https://pingcap.co.jp/contact-us/$1; } return 301 https://en.pingcap.com/contact-us/$1; } location ~ ^/case-studies/(.*) { return 301 https://en.pingcap.com/case-study/$1; } location /legal { if ($lang_new ~ "ja") { return 301 https://pingcap.co.jp/legal/; } return 301 https://en.pingcap.com/legal; } location /products/tidbcloud { if ($lang_new ~ "ja") { return 301 https://pingcap.co.jp/tidb-cloud/; } return 301 https://en.pingcap.com/tidb-cloud/; } location ~ ^/event { if ($lang_new ~ "ja") { return 301 https://pingcap.co.jp/event/; } return 301 https://en.pingcap.com$request_uri; } location / { if ($lang_new ~ "ja") { return 301 https://pingcap.co.jp; } return 301 https://en.pingcap.com$request_uri; } }