server {
    server_name  www.penobscotbaypress.com;
    rewrite ^(.*) https://penobscotbaypress.com$1 permanent;
}
server {
    server_name  directory.penobscotbaypress.com;
    rewrite ^(.*) https://penobscotbaypress.com/directory$1 permanent;
}

server {
    server_name  store.penobscotbaypress.com;
    rewrite ^(.*) https://penobscotbaypress.com/store/ permanent;
}

server {
    listen   80;
    server_name  penobscotbaypress.com;
    rewrite ^(.*) https://penobscotbaypress.com$1 permanent;
}

server {
#	listen   80;
        listen   443 ssl; 
	server_name penobscotbaypress.com;

    ssl  on;
    ssl_certificate     /etc/nginx/penobscotbaypress.com.chained.crt;
    ssl_certificate_key /etc/nginx/penobscotbaypress.key;
    ssl_ciphers RC4:HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;

	access_log  /var/log/nginx/pbp.access.log;

	location /robots.txt {
		alias /var/lib/django/pbp_com/templates/robots.txt;
        }
        
	location /images/headers/iaflaground440.gif {
		rewrite /images/headers/iaflaground440.gif http://penobscotbaypress.com/media/images/headers/iaflaground440.gif permanent;
	}

	location /index.html { 
		rewrite /index.html http://penobscotbaypress.com/ permanent;
	}

	location /penobscotbaypress.xml {
		rewrite /penobscotbaypress.xml http://penobscotbaypress.com/news/feed.xml permanent;
 	}
		

	location /webcam/iawebcam.html { 
		rewrite /webcam/iawebcam.html http://penobscotbaypress.com/multimedia/webcams/stonington/ permanent;
	}

	location /webcam/pbpcam.jpg { 
		rewrite /webcam/pbpcam.jpg http://webcam.penobscotbaypress.com/pbpcam.jpg permanent;
	}

	location /webcam/wpwebcam.html { 
		rewrite /webcam/wpwebcam.html http://penobscotbaypress.com/multimedia/webcams/blue-hill/ permanent;
	}

	location /store/shoppingcart.html { 
		rewrite /store/shoppingcart.html http://penobscotbaypress.com/store/ permanent;
	}

	location /store/wishlist.html { 
		rewrite /store/wishlist.html http://penobscotbaypress.com/store/ permanent;
	}

	location /store/help.html { 
		rewrite /store/help.html http://penobscotbaypress.com/store/ permanent;
	}

	location /store/privacy.html { 
		rewrite /store/privacy.html http://penobscotbaypress.com/store/ permanent;
	}

	location /classifieds/compassclassifieds.html {
    		rewrite /classifieds/compassclassifieds.html http://penobscotbaypress.com/classifieds/ permanent;
	}
	location /communityinformation/remembrances/deathannouncements.html {
		rewrite /communityinformation/remembrances/deathannouncements.html http://penobscotbaypress.com/remembrances/death-announcements/ permanent;
        }

	location /communityinformation/towninformation/deerisle.html {
		rewrite /communityinformation/towninformation/deerisle.html http://penobscotbaypress.com/community-info/towns/deer-isle/ permanent;
	}

	location /captainsquarters/* {
    		rewrite /captainsquarters/ http://penobscotbaypress.com/news/archives/ permanent;
	}
	location /captainsquarters/ {
    		rewrite /captainsquarters/ http://penobscotbaypress.com/news/archives/ permanent;
	}

	location /admin/orders_admin.html {
    		rewrite /admin/orders_admin.html http://old.penobscotbaypress.com/admin/orders_admin.html permanent;
	}

        location /calendar/communitycalendar.html {
		rewrite /calendar/communitycalendar.html http://calendar.penobscotbaypress.com permanent;
        }

	location /communitynews/ {
		rewrite /communitynews/.* http://old.penobscotbaypress.com/communitynews/$1 redirect;
        }
        
	location /images/ {
		rewrite ^(/images/.*) http://old.penobscotbaypress.com/$1 redirect;
        }

	location /styles.css {
		rewrite /styles.css http://old.penobscotbaypress.com/styles.css redirect;
        }
	location /store/images/ {
		rewrite /store/images/ http://old.penobscotbaypres.com/store/images/ permanent;
	}

	location /store/books/ {
		rewrite ^(.*) http://penbaypress.me/ permanent;
	}

        location /cgi-bin/redirect.pl {
		rewrite /cgi-bin/redirect.pl http://old.penobscotbaypress.com/cgi-bin/redirect.pl permanent;
        }
        
        # added for admin static files
        location /static/ {
            alias /var/lib/django/pbp_com/static_collected/;
        }

	# site_media - folder in uri for static files
        location ^~ /media/ {
		root /var/lib/django/pbp_com/;
                access_log   off;
                expires      30d;
        }
	
        location = /favicon.ico  {
        	rewrite "/favicon.ico" /media/images/favicon.ico;
	}

	location / {
		include /etc/nginx/uwsgi_params;
		uwsgi_pass unix:/var/lib/django/run/pbp_com.sock;
	}

}
