Hi guys!
i just switched to nginx. I can't handle to define a virtualhost which serves both site.xxx and www.site.xxx.
Here is my nginx.conf:
- if I try to access site.xxx I get the index.php as normal
- if I try to access www.site.xxx I get a binary file to download (which is the index.php)
- I noticed that loggin in site.xxx and then going to site.xxx/whiceverpage gives me the right page as logged, instead loggin in site.xxx and then going to www.site.xxx/whiceverpage gives me the login page as the session isn't the same created with the first login.
What the hell am I doing wrong?
Thanks for the help guys.
user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type text/plain;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
fastcgi_intercept_errors on;
sendfile on;
keepalive_timeout 65;
gzip on;
index index.php index.html index.htm;
server {
listen 80;
server_name site.com www.site.com;
root /home/vhosts/site;
location / {
try_files $uri $uri/ /index.php index.php;
}
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location ~* \.php$ {
try_files $uri =404;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
}
}