Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My site's been running fine on nginx for years. Have SSL and non-SSL locations. PHP runs through .shtml files

Working on a Facebook app and right now need to have it work with both the SSL and non-SSL URL. Testing the coding on my server right now. I can't get it to work in the SSL config.

If I go to http://www.example.com/myappsname the page loads.

https://www.example.com/myappsname/index.shtml the page loads. <-note https

https://www.example.com/myappsname/ the page tosses a 404

Here are the relevant locations in the SSL server section:

location / {
root /usr/local/apache/htdocs;
rewrite ^(.+) http://www.example.com$1 permanent;
index index.shtml index.php;
}

location ~ \.(shtml|php|inc)$ {
root /usr/local/apache/htdocs;
include /usr/local/nginx/conf/fastcgi-php.conf;
fastcgi_pass 127.0.0.1:10004;
}

location ^~ /myappsname/ {
index index.shtml;
root /usr/local/apache/htdocs/;
fastcgi_intercept_errors on;
include /usr/local/nginx/conf/fastcgi-php.conf;
fastcgi_pass 127.0.0.1:10004;
fastcgi_param HTTPS on;
}

I'll probably smack my head when this is pointed out to me. All my other SSL locations work fine. Any idea why including the filename stays SSL but dropping it redirects?

share|improve this question
    
What's there in fastcgi-php.conf? It can be relevant. –  rvs Sep 3 '11 at 8:35

1 Answer 1

With the config that you've provided, https://www.example.com/myappsname/ does not redirect, however, https://www.example.com/myappsname does, as it doesn't match the prefix search of location ^~ /myappsname/.

Your description uses a trailing slash for the HTTPS URL, but none on the HTTP URL - I'm guessing that this isn't quite accurate, and that you're seeing the redirect improperly occurring only when the trailing slash is absent from the HTTPS URL.

If this is the case, fix your prefix match - drop the trailing slash, or just set up a location = /myappsname?

share|improve this answer
    
Just did another test location ^~ /myappsname/, location ^~ /myappsname and location /myappsname/ all resulted in a 404. Really hurting my head...the other ssl locations are fine. :-( –  Ian Sep 3 '11 at 8:26
    
@Ian That's not hitting the redirect in the / location block, so, that's what we're going for.. are your root and index directives for your test block set up to serve up the right page in the test location? Maybe just use location = /myappsname for testing to be absolutely sure of which config you're hitting.. –  Shane Madden Sep 3 '11 at 8:36
    
changing to location = /myappsname stops the 404 but now redirects to the http version, which doesn't fit in with facebook's move to ssl. Still don't understand why this location isn't working but the other ssl locations are. A real head scratcher. –  Ian Sep 3 '11 at 8:49
    
Looking at the debug log a call to /myappsname isn't matching the /myappsname location. Sigh... –  Ian Sep 3 '11 at 9:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.