Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NGINX Proxy to Apache #59

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions inc/plugins/google_seo/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,23 @@ function google_seo_plugin_apply($apply=false)
'}',
),
);

// build_profile_link
$edits[] = array(
'search' => array('return "<a href=\\"{$mybb->settings[\'bburl\']}/".get_profile_link($uid)."\\"{$target}{$onclick}>{$username}</a>";'),
'before' => array(
'if(function_exists("google_seo_url_profile"))',
'{',
' $link = google_seo_url_profile($uid);',
'',
' if ($link)',
' {',
' return "<a href=\"{$link}\"{$target}{$onclick}>{$username}</a>";',
' }',
'}',
),
);

}

if($settings['google_seo_url_announcements'])
Expand Down
7 changes: 7 additions & 0 deletions inc/plugins/google_seo/redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ function google_seo_redirect_hook()
// Never touch posts.
return;
}

$rewritten = $mybb->get_input('rewritten', MyBB::INPUT_INT);
if ($rewritten)
{
// The URLs were already rewritten by the front-end webserver
return;
}

// Build the target URL we should be at:
switch(THIS_SCRIPT)
Expand Down
2 changes: 1 addition & 1 deletion inc/plugins/google_seo/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ function google_seo_url_cache($type, $id)
}

// Return the cached entry for the originally requested type and id.
return $google_seo_url_cache[$type][$id];
return $settings['bburl'] . '/' . $google_seo_url_cache[$type][$id];
}

/*
Expand Down
48 changes: 48 additions & 0 deletions rewrite-nginx-apache.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
A tutorial for getting rewrite rules (MyBB SEF style) work with nginx:

http://community.mybboard.net/thread-51764.html

The same method can be applied for Google SEO rewrite rules, but you
have to create those rules manually. Google SEO can not detect that
you are not using Apache, and will only generate .htaccess rules.

Here is an example of what nginx rules for Google SEO look like:

# Google SEO workaround for search.php highlights:
# Make this rule the first rewrite rule in your .htaccess!
rewrite ^/MyBB/([^&]*)&(.*)$ http://yoursite/MyBB/$1?$2 permanent;

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

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

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

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

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

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

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

# In the event the server is using both NGINX and Apache,
# the URLs should have `rewritten` set to `1`.

# Sets rewritten so that when the rewritten URL is proxied to Apache,
# the plugin won't try to redirect the user (causing an infinite loop,
# by redirecting to the SEO url, which is rewritten by NGINX and proxied to
# Apache, then redirected, etc.)
if ($is_args) {
set $args "$args&rewritten=1";
}

# Proxy pass below
proxy_pass http://127.0.0.1:8001$uri$is_args$args
1 change: 1 addition & 0 deletions rewrite-nginx.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ Here is an example of what nginx rules for Google SEO look like:

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