Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- server {
- listen 80;
- server_name example.com www.example.com;
- location / {
- rewrite ^/sub1/?(.*)$ https://sub1.example.com/$1 permanent;
- rewrite ^/sub2/?(.*)$ https://sub2.example.com/$1 permanent;
- rewrite ^/sub3/?(.*)$ https://sub3.example.com/$1 permanent;
- rewrite ^/sub4/?(.*)$ https://sub4.example.com/$1 permanent;
- return 301 https://$host$request_uri;
- }
- }
- server {
- listen 443 ssl;
- root /var/www/example.com;
- index index.php index.html index.htm;
- server_name example.com www.example.com;
- access_log /var/log/nginx/example.com.access.log;
- error_log /var/log/nginx/example.com.error.log;
- include snippets/ssl-example.conf;
- include snippets/ssl-params.conf;
- set $cache_uri $request_uri;
- # POST requests and URLs with a query string should always go to PHP
- if ($request_method = POST) {
- set $cache_uri 'null cache';
- }
- if ($query_string != "") {
- set $cache_uri 'null cache';
- }
- # Don't cache URIs containing the following segments
- if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php
- |wp-.*.php|/feed/|index.php|wp-comments-popup.php
- |wp-links-opml.php|wp-locations.php |sitemap(_index)?.xml
- |[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
- set $cache_uri 'null cache';
- }
- # Don't use the cache for logged-in users or recent commenters
- if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+
- |wp-postpass|wordpress_logged_in") {
- set $cache_uri 'null cache';
- }
- # Use cached or actual file if it exists, otherwise pass request to WordPress
- location / {
- rewrite ^/sub1/?(.*)$ https://sub1.example.com/$1 permanent;
- rewrite ^/sub2/?(.*)$ https://sub2.example.com/$1 permanent;
- rewrite ^/sub3/?(.*)$ https://sub3.example.com/$1 permanent;
- rewrite ^/sub4/?(.*)$ https://sub4.example.com/$1 permanent;
- try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html
- $uri $uri/ /index.php;
- }
- location ~ .php$ {
- try_files $uri /index.php;
- include fastcgi_params;
- fastcgi_pass unix:/var/run/php5-fpm.sock;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- }
- location = /favicon.ico {
- log_not_found off;
- access_log off;
- }
- location = /robots.txt {
- log_not_found off;
- access_log off;
- }
- # Cache static files for as long as possible
- location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
- expires max;
- log_not_found off;
- access_log off;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement