Posted by jason ruyle on October 6, 2014 at 10:09pm
We have a configuration issue right now and I'm guessing others have experienced it.
We run a site that uses paths like:
/wishlist/ajax/js
/rental/ajax/js
When running on our staging area (on same server) they return the proper results (the ajax update is called and things work correctly).
When we run it on our https version of the site, they return a 404 error.
POST https://oursite.com/wishlist/ajax/js 404 (Not Found)
On the https version of the site, if I change the url to:
/?q=wishlist/ajax/js
Things work correctly again.
What am I missing here?
We moved from apache to nginx. Anyone know a reason for this? I can provide our configuration files if needed.

Comments
check your rewrite for js and
check your rewrite for js and php in your nginx config file, you might have two configs one for http and one for https, are you using perusio's version of nginx config files?
If they look the same, it is probably the permissions to the directrory (private or not)
I'll take a look at my conf
I'll take a look at my conf files, if you dont mind ill post here as well. Maybe someone can see something I don't.
nginx.conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 75;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
client_max_body_size 500M;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/.conf;
include /etc/nginx/sites-enabled/;
}
There is nothing in my conf.d folder.
I run two sites - staging and ssl.
staging
server {
listen 80;
listen [::]:80;
root /var/www/staging/docroot/production;
index index.php index.html index.htm;
server_name staging.mysite.com;
location = /info {
allow 127.0.0.1;
deny all;
rewrite (.*) /.info.php;
}
include /etc/nginx/custom.conf;
}
custom.conf
# Enable compression, this will help if you have for instance advagg module
# by serving Gzip versions of the files.
gzip_static on;
location ~ ../..php$ {
return 403;
}
# No no for private
location ~ ^/sites/./private/ {
return 403;
}
# Block access to "hidden" files and directories whose names begin with a
# period. This includes directories used by version control systems such
# as Subversion or Git to store control files.
location ~ (^|/). {
return 403;
}
# This matters if you use drush
location = /backup {
deny all;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_read_timeout 300;
}
location / {
# This is cool because no php is touched for static content
try_files $uri @rewrite;
}
# Image styles for D7
location ~ /sites/./files/styles/ {
access_log off;
expires 30d;
try_files $uri @rewrite;
}
location @rewrite {
# For D7 and above:
# Clean URLs are handled in drupal_environment_initialize().
rewrite ^ /index.php;
# Some modules enforce no slash (/) at the end of the URL
# Else this rewrite block wouldn't be needed (GlobalRedirect)
#rewrite ^/(.)$ /index.php?q=$1;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
## Replicate the Apache <FilesMatch> directive of Drupal standard
## .htaccess. Disable access to any code files. Return a 404 to curtail
## information disclosure. Hide also the text files.
location ~* ^(?:.+.(?:htaccess|make|txt|engine|inc|info|install|module|profile|po|pot|sh|.sql|test|theme|tpl(?:.php)?|xtmpl)|code-style.pl|/Entries.|/Repository|/Root|/Tag|/Template)$ {
return 404;
}
## Disable logging of certain files
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml|svg)$ {
access_log off;
expires 30d;
}
ssl
server {
listen 80 default_server;
#listen [::]:80 ipv6only=on;
listen [::]:80 default_server ipv6only=on;
listen 443 default spdy ssl;
listen [::]:443 ipv6only=on default spdy ssl;
root /var/www/mysite/docroot;
index index.php index.html index.htm;
server_name mysite.com www.mysite.com;
include /etc/nginx/customssl.conf;
ssl_certificate /etc/ssl/certs/mysite_bundle.crt;
ssl_certificate_key /etc/ssl/private/mysite.com.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5:!kEDH;
ssl_prefer_server_ciphers on; #disable BEAST attack
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 20m;
add_header Strict-Transport-Security "max-age=31536000";
}
customssl.conf
# Enable compression, this will help if you have for instance advagg module
# by serving Gzip versions of the files.
gzip_static on;
# Redirect all traffic to https.
#if ($ssl_protocol = "") {
# rewrite ^ https://$server_name$request_uri? permanent;
#}
fastcgi_param HTTPS $https if_not_empty;
## If you're using a Nginx version greater or equal to 1.1.4 then
## you can use keep alive connections to the upstream be it
## FastCGI or Apache. If that's not the case comment out the line below.
fastcgi_keep_conn on; # keep alive to the FCGI upstream
location ~ ../..php$ {
return 403;
}
# No no for private
location ~ ^/sites/./private/ {
return 403;
}
# Block access to "hidden" files and directories whose names begin with a
# period. This includes directories used by version control systems such
# as Subversion or Git to store control files.
location ~ (^|/). {
return 403;
}
# This matters if you use drush
location = /backup {
deny all;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_read_timeout 300;
}
location / {
# This is cool because no php is touched for static content
try_files $uri @rewrite;
}
# Image styles for D7
location ~ /sites/./files/styles/ {
access_log off;
expires 30d;
try_files $uri @rewrite;
}
location @rewrite {
# For D7 and above:
# Clean URLs are handled in drupal_environment_initialize().
rewrite ^ /index.php;
# Some modules enforce no slash (/) at the end of the URL
# Else this rewrite block wouldn't be needed (GlobalRedirect)
#rewrite ^/(.)$ /index.php?q=$1;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
## Replicate the Apache <FilesMatch> directive of Drupal standard
## .htaccess. Disable access to any code files. Return a 404 to curtail
## information disclosure. Hide also the text files.
location ~* ^(?:.+.(?:htaccess|make|txt|engine|inc|info|install|module|profile|po|pot|sh|.sql|test|theme|tpl(?:.php)?|xtmpl)|code-style.pl|/Entries.|/Repository|/Root|/Tag|/Template)$ {
return 404;
}
## Disable logging of certain files
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml|svg)$ {
access_log off;
expires 30d;
}
On the https version of the
This saved my day :-) Thank you .. I solved it by using the /?q= method .. I use Nginx, SSL and POST via jQuery and was facing a similar strange 404 error.. Now it is working.. Thank you.. If anyone knows what should be done in Nginx config file to resolve the original issue, then let us know..