MyBB Community Forums

Full Version: nginx vhost conf/rewrite issues
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi all,

I'm hoping someone who is more experienced with nginx can lend a hand here...recent convert from apache.  I did not have this issue when using apache so my guess is that it's an nginx conf/rewrite issue somewhere.

for some reason, a second slash is being added to some links on my forum...ex: http://mysite.com//thread-blah.  for some reason when I try to have www.mysite.com redirect to mysite.com, it's adding a double slash as well.

for mybb, I'm using google seo and I have "Enable search engine friendly URLs?" disabled in the admin cp.

here's my nginx vhost conf:

#server {
         #server_name www.mysite.com;
         #return 301 $scheme://mysite.com$request_uri;
        #}
 
        server {
         listen 80 default_server;
         listen [::]:80 default_server ipv6only=on;
 
         root /sites/public_html;
         index index.php index.html index.htm;
 
         # Make site accessible from http://localhost/
         server_name mysite.com www.mysite.com;
 
         # Logs
         access_log /sites/logs/access.log;
         error_log /sites/logs/error.log info;
 
         location /inc {
                deny all;
                return 403;
        }
 
         location / {
 
                autoindex on;
 
                #Mybb Rewrites
                rewrite ^/([^&]*)&(.*)$ http://mysite.com/$1?$2 permanent;
 
                # Google SEO Sitemap:
                rewrite ^/((?i)sitemap-([^./]+)\.xml)$ /misc.php?google_seo_sitemap=$2;
 
                # Google SEO URL Forums:
                rewrite ^/((?i)forum-([^./]+))$ /forumdisplay.php?google_seo_forum=$2;
 
                # Google SEO URL Threads:
                rewrite ^/((?i)thread-([^./]+))$ /showthread.php?google_seo_thread=$2;
 
                # Google SEO URL Announcements:
                rewrite ^/((?i)announcement-([^./]+))$ /announcements.php?google_seo_announcement=$2;
 
                # Google SEO URL Users:
                rewrite ^/((?i)user-([^./]+))$ /member.php?action=profile&google_seo_user=$2;
 
                # Google SEO URL Calendars:
                rewrite ^/((?i)calendar-([^./]+))$ /calendar.php?google_seo_calendar=$2;
 
                # Google SEO URL Events:
                rewrite ^/((?i)event-([^./]+))$ /calendar.php?action=event&google_seo_event=$2;
 
                try_files $uri $uri/ =404;
 
        }
 
         error_page 404 /404.html;
         error_page 500 502 503 504 /50x.html;
         location = /50x.html {
                root /usr/share/nginx/html;
        }
 
         location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}
Is it caused by that slash there? I think it's the only place I can see where that'd be getting added.

#Mybb Rewrites
rewrite ^/([^&]*)&(.*)$ http://mysite.com/$1?$2 permanent;
(2016-01-12, 10:44 AM)Cameron:D Wrote: [ -> ]Is it caused by that slash there? I think it's the only place I can see where that'd be getting added.

#Mybb Rewrites
rewrite ^/([^&]*)&(.*)$ http://mysite.com/$1?$2 permanent;

that's what a friend thought it was who is versed in nginx as well, but it didn't solve the problem.

It's a tricky issue. our navbar, 100%, causes a double slash to be added to a url, but then so do a couple links, like http://mysite.com/search.php?action=getnew, http://mysite.com/search.php?action=getdaily, etc...

here's part of my header template where the navbar links are...note, we tried both absolute and relative links to see if one or the other was causing the problem...both still add the double slash.

<ul class="menu sf-menu">
				{$menu_portal}

				{$menu_calendar}
<li><a href="forumdisplay.php?fid=13">Shaving &amp; Grooming</a></li>
<li><a href="{$mybb->settings['bburl']}/forumdisplay.php?fid=25">Show &amp; Tell</a></li>
<li><a href="{$mybb->settings['bburl']}/forumdisplay.php?fid=8">Shopping</a></li>
<li><a href="{$mybb->settings['bburl']}/forumdisplay.php?fid=21">Outside the Box</a></li>
				<li>{$menu_search}</li>
				<li><a href="{$mybb->settings['bburl']}/search.php?action=getdaily">Latest Posts</a></li>
			</ul>

I can PM you a link if you'd like to look some more.

edit: I think I might of found the issue...waiting until I confirm with a friend of mine in the morning.
ok, I believe the issue was the apache proxy config I was using to proxy connections from my old server to the new server. The proxy is still in place until the recent DNS changes propagate around the world.