Not Solved Cloudflare SSL Page Rule with nginx and Google SEO
#1
Not Solved
Regular http works fine on this live test environment.

I have enabled a page rule forcing http://*htpcguides.casa/forum/* to be SSL which works fine for some URLs.  I tried http://*htpcguides.casa/forum/*/* based on the page rules doc https://blog.cloudflare.com/introducing-...eature-co/

The URLs that are not working seem to be ones related to the Google SEO plugin related, I have the required rewrite rules in my nginx config. Admin pages work fine.

Example URL not working https://www.htpcguides.casa/forum/user-blindpet and https://www.htpcguides.casa/forum/forum-Chat

https://www.htpcguides.casa/forum works just fine as does registering and logging in

Anybody managed to make this pariticular setup work?

Here is the nginx config in case, the reason the port is 8001 is because of a reverse proxy

fastcgi_cache_path /etc/nginx/cache/mybb levels=1:2 keys_zone=fastcgicache:10m inactive=10m max_size=100m;
fastcgi_cache_lock on;
fastcgi_cache_use_stale error timeout invalid_header updating http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

server {
 server_name www.htpcguides.casa htpcguides.casa;
 listen 8001;
 access_log   /var/log/nginx/htpcguides.forum.access.log;
 error_log    /var/log/nginx/htpcguides.forum.error.log;
 port_in_redirect off;

 root /var/www/;
 index index.php index.htm index.html;

 fastcgi_cache_key "$host$cookie_sid$request_method$uri$args";
 
 location /forum {
 server_tokens off;
 try_files $uri $uri/ /index.php?$args;
 rewrite ^/forum-([0-9]+)\.html$ /forumdisplay.php?fid=$1;
 rewrite ^/forum-([0-9]+)-page-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2;
 rewrite ^/thread-([0-9]+)\.html$ /showthread.php?tid=$1;
 rewrite ^/thread-([0-9]+)-page-([0-9]+)\.html$ /showthread.php?tid=$1&page=$2;
 rewrite ^/thread-([0-9]+)-lastpost\.html$ /showthread.php?tid=$1&action=lastpost;
 rewrite ^/thread-([0-9]+)-nextnewest\.html$ /showthread.php?tid=$1&action=nextnewest;
 rewrite ^/thread-([0-9]+)-nextoldest\.html$ /showthread.php?tid=$1&action=nextoldest;
 rewrite ^/thread-([0-9]+)-newpost\.html$ /showthread.php?tid=$1&action=newpost;
 rewrite ^/thread-([0-9]+)-post-([0-9]+)\.html$ /showthread.php?tid=$1&pid=$2;
 rewrite ^/post-([0-9]+)\.html$ /showthread.php?pid=$1;
 rewrite ^/announcement-([0-9]+)\.html$ /announcements.php?aid=$1;
 rewrite ^/user-([0-9]+)\.html$ /member.php?action=profile&uid=$1;
 rewrite ^/calendar-([0-9]+)\.html$ /calendar.php?calendar=$1;
 rewrite ^/calendar-([0-9]+)-year-([0-9]+)\.html$ /calendar.php?action=yearview&calendar=$1&year=$2;
 rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ /calendar.php?calendar=$1&year=$2&month=$3;
 rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ /calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4;
 rewrite ^/calendar-([0-9]+)-week-(n?[0-9]+)\.html$ /calendar.php?action=weekview&calendar=$1&week=$2;
 rewrite ^/event-([0-9]+)\.html$ /calendar.php?action=event&eid=$1;
 rewrite ^/archive/index.php/forum-([0-9]+)\.html$ /forum/archive/index.php?forum-$1.html;
 rewrite ^/archive/index.php/thread-([0-9]+)\.html$ /forum/archive/index.php?thread-$1.html;
 
 # Google SEO mybb plugin workaround for nginx:
 # Make this rule the first rewrite rule in your .htaccess!
 rewrite ^/forum/([^&]*)&(.*)$ http://www.htpcguides.casa/forum/$1?$2 permanent;

 # Google SEO Sitemap:
 rewrite ^/forum/((?i)sitemap-([^./]+)\.xml)$ /forum/misc.php?google_seo_sitemap=$2;

 # Google SEO URL Forums:
 rewrite ^/forum/((?i)forum-([^./]+))$ /forum/forumdisplay.php?google_seo_forum=$2;

 # Google SEO URL Threads:
 rewrite ^/forum/((?i)thread-([^./]+))$ /forum/showthread.php?google_seo_thread=$2;

 # Google SEO URL Announcements:
 rewrite ^/forum/((?i)announcement-([^./]+))$ /forum/announcements.php?google_seo_announcement=$2;

 # Google SEO URL Users:
 rewrite ^/forum/((?i)user-([^./]+))$ /forum/member.php?action=profile&google_seo_user=$2;

 # Google SEO URL Calendars:
 rewrite ^/forum/((?i)calendar-([^./]+))$ /forum/calendar.php?google_seo_calendar=$2;

 # Google SEO URL Events:
 rewrite ^/forum/((?i)event-([^./]+))$ /forum/calendar.php?action=event&google_seo_event=$2;
 }

 location ~* \.(jpg|jpeg|gif|png|css|ico|js|xml)$ {
 access_log        off;
 log_not_found     off;
 expires           360d;
 }

 location ~ ^/(bin|SQL|\.ht)/ {
 deny all;
 }
   
 ##This passes the php to the socket for processing for both Wordpress and myBB thanks to the bottom line
 location ~ \.php$ {
 try_files $uri =404;
 include fastcgi_params;
 fastcgi_pass unix:/var/run/php5-fpm.sock;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 add_header X-Cache $upstream_cache_status;
 fastcgi_cache fastcgicache;
 fastcgi_cache_bypass $cookie_mybbuser $cookie_adminsid;
 fastcgi_no_cache $cookie_mybbuser $cookie_adminsid;
 fastcgi_cache_valid  200 302 15m;
 fastcgi_cache_valid  301 1d;
 fastcgi_cache_valid  404 5m;
 fastcgi_cache_valid  403 5m;
 fastcgi_cache_valid  any 15m;
 }
}
Reply
#2
Not Solved
This user has been denied support. This user has been denied support.
Unfortunately there is no direct way for PHP to tell whether the browser/webserver is using HTTPS or no. The situation is worse when using proxies (such as cloudflare) where the proxy uses HTTPS to the client but the connection between proxy and webserver is just regular http.

If you know that the request is coming in through https, set an env var for PHP ($_SERVER[HTTPS]=on).
Reply
#3
Not Solved
Thanks, where do I set that env var exactly?

Edit redirect.php in the Googleseo plugin folder

Under the first comments I added

putenv($_SERVER[HTTPS]=on);

with the Cloudflare page rule to force ssl http://*htpcguides.casa/forum/* it all works now!
Reply
#4
Not Solved
(2015-07-24, 09:31 AM)blindpet Wrote: Thanks, where do I set that env var exactly?

Edit redirect.php in the Googleseo plugin folder

Under the first comments I added

putenv($_SERVER[HTTPS]=on);

with the Cloudflare page rule to force ssl  http://*htpcguides.casa/forum/* it all works now!

I'm getting a 404 Not found on your forum, does it really work?
Reply
#5
Not Solved
That was the test domain, the real domain is https://forum.htpcguides.com. I switched to a subdomain because it made more sense in terms of separation. The configuration did work though and is active on my live forum.
Reply
#6
Not Solved
(2015-09-02, 08:26 PM)blindpet Wrote: That was the test domain, the real domain is https://forum.htpcguides.com

So everything went fine with the solution above?

Thanks
Reply
#7
Not Solved
Yes, everything went well with what I wrote Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)