Are you using nginx frontend - apache backend or pure nginx or pure apache?The site don't work. The Wordpress (different domains) on the same server work just fine but the forum doesn't. I can see it running Apache but not on nginx. I don't know what's wrong.
Right now I'm using nginx. Apache is stopped.Are you using nginx frontend - apache backend or pure nginx or pure apache?
I don't see how you could run PHP without a fastcgi_pass, is probably into an include file.OK, I commented out #fastcgi_pass 127.0.0.1:9000; in nginx config and all work fine now.
server {
## listen for ipv4; this line is default and implied
listen 80;
server_name www.domain.com domain.com;
## rewrite www, try to keep your internal linking consistent
#rewrite ^(.*)$ http://domain.com$request_uri? permanent; (for some reason, this doesn't work).
root /var/www/vhosts/maindomain.com/domain.com.folder;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
try_files $uri $uri/ /index.php?$uri&$args;
index index.php index.html;
}
#protect the innocent
location /(internal_data|library)/ {
internal;
}
location ~ \.php$ {
try_files $uri =404;
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
## Robots.txt to Xenforo
location /robots.txt {
rewrite ^(.*)$ http://domain.com/index.php?xfa-robots/index ;
}
# 301 Permanent URL Redirects
location ~ /forum/$ {
rewrite ^(.*)$ / permanent;
}
# static resource routing - favicon.ico
location ~* ^/favicon.ico {
# Per RFC2616 - 1 year maximum expiry
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
expires 1y;
add_header Cache-Control public;
# Some browsers still send conditional-GET requests if there's a
# Last-Modified header or an ETag header even if they haven't
# reached the expiry date sent in the Expires header.
add_header Last-Modified "";
add_header ETag "";
break;
}
#gzip it, gzip it good
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_min_length 1100;
gzip_buffers 64 8k;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
#add some expires
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 1y;
log_not_found off;
}
# deny access to apache .htaccess files
location ~ /\.ht
{
deny all;
}
}
Where do you get that configuration?I really have no idea...
This is my config.
Code:server { ## listen for ipv4; this line is default and implied listen 80; server_name www.domain.com domain.com; ## rewrite www, try to keep your internal linking consistent #rewrite ^(.*)$ http://domain.com$request_uri? permanent; (for some reason, this doesn't work). root /var/www/vhosts/maindomain.com/domain.com.folder; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location / { try_files $uri $uri/ /index.php?$uri&$args; index index.php index.html; } #protect the innocent location /(internal_data|library)/ { internal; } location ~ \.php$ { try_files $uri =404; #fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } ## Robots.txt to Xenforo location /robots.txt { rewrite ^(.*)$ http://domain.com/index.php?xfa-robots/index ; } # 301 Permanent URL Redirects location ~ /forum/$ { rewrite ^(.*)$ / permanent; } # static resource routing - favicon.ico location ~* ^/favicon.ico { # Per RFC2616 - 1 year maximum expiry # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html expires 1y; add_header Cache-Control public; # Some browsers still send conditional-GET requests if there's a # Last-Modified header or an ETag header even if they haven't # reached the expiry date sent in the Expires header. add_header Last-Modified ""; add_header ETag ""; break; } #gzip it, gzip it good gzip on; gzip_http_version 1.1; gzip_vary on; gzip_min_length 1100; gzip_buffers 64 8k; gzip_comp_level 2; gzip_proxied any; gzip_types text/plain text/css application/x-javascript text/xml application/xml; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; #add some expires location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires 1y; log_not_found off; } # deny access to apache .htaccess files location ~ /\.ht { deny all; } }
server {
## listen for ipv4; this line is default and implied
listen 80;
server_name www.domain.com domain.com;
## rewrite www, try to keep your internal linking consistent
#rewrite ^(.*)$ http://domain.com$request_uri? permanent; (for some reason, this doesn't work).
root /var/www/vhosts/maindomain.com/domain.com.folder;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
server {
listen 80;
server_name www.domain.com;
return 301 http://domain.com$request_uri;
}
server {
listen 80;
server_name domain.com;
....
}
# 301 Permanent URL Redirects
location ~ /forum/$ {
rewrite ^(.*)$ / permanent;
}
# static resource routing - favicon.ico
location ~* ^/favicon.ico {
# Per RFC2616 - 1 year maximum expiry
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
expires 1y;
add_header Cache-Control public;
#add some expires
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 1y;
log_not_found off;
}
Sweet! That works fine!You try to redirect www to non www but failed? I guess maybe because you had www.domain.com in server_name. Try this:
Removed.What is this favicon location function if you had...
You do use fastcgi_pass: fastcgi_pass unix:/var/run/php5-fpm.sock;I really have no idea...
Wow, thanks!Where did you get that configuration? There are a lot of things wrong with it:
location /oldpage/15/ {
rewrite ^(.*)$ http://domain.com/newpage/341/ permanent;
}
location /oldpage/16/ {
rewrite ^(.*)$ http://domain.com/newpage/812/ permanent;
}
server {
listen 80;
server_name www.domain.com;
return 301 http://domain.com$request_uri;
}
server {
listen 80;
server_name domain.com;
access_log /var/log/nginx/domain-access.log;
error_log /var/log/nginx/domain-error.log;
root /var/www/vhosts/maindomain.com/domain;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$uri&$args;
}
location ~ ^/(internal_data|library)/ {
internal;
allow 127.0.0.1;
deny all;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(?:ico|css|gif|jpe?g|js|png|swf)$ {
access_log off;
log_not_found off;
expires 1y;
}
## Robots.txt to Xenforo
location /robots.txt {
rewrite ^(.*)$ http://domain.com/index.php?xfa-robots/index ;
}
## 301 Permanent URL Redirects
.....
}
server {
listen 192.168.1.2:80;
server_name _;
return 301 http://domain.com$request_uri;
}
location /data {
location ~ \.html$ {
internal;
}
internal;
}
location /internal_data {
location ~ \.(?:data|html|php)$ {
internal;
}
internal;
}
location /library {
location ~ \.(?:default|html|php|txt|xml)$ {
internal;
}
internal;
}
location = /robots.txt {
return 301 http://domain.com/index.php?xfa-robots/index;
}
include localhost.redirect;
}
location /oldpage {
location = /oldpage/15/ {
return 301 http://domain.com/newpage/341/;
}
location = /oldpage/16/ {
return 301 http://domain.com/newpage/812/;
}
...
}
This is not redirecting www.domain.com to domain.com but www.domain.com to a another domain hosted in a sub directory on the same server.Code:server { listen 192.168.1.2:80; server_name _; return 301 http://domain.com$request_uri; }
server {
listen 80;
server_name www.domain.com;
return 301 http://domain.com$request_uri;
}
I'm getting this when restarting nginx:5) For your redirects, I would add them on a separate file so I don't clutter the main config.
The message is clear, no? Sorry, I don't spoon feed.I'm getting this when restarting nginx:
nginx: [emerg] "location" directive is not allowed here in /etc/nginx/sites-available/localhost.redirect:2
Three hours before I write this post I was searching for a solution and when I realized that I can't make it work, I asked for help. If my message bothered, you could ignore it.The message is clear, no? Sorry, I don't spoon feed.
We use essential cookies to make this site work, and optional cookies to enhance your experience.