redirect - Strange subdomain issue in NGINX -


what want is:

  • to redirect www.domain.com , domain.com https://domain.com
  • to forward subdomain.domain.com , domain.com same directory
  • to forward backend.domain.com seperate directory

to job done i'm using configuration above. redirect subdomains https://domain.com. tried , without second server block of code (redirect block).

what doing wrong?

server {     ssl on;     ssl_certificate /etc/nginx/ssl/cert_chain.crt;     ssl_certificate_key /etc/nginx/ssl/server.key;     charset utf-8;     client_max_body_size 128m;      listen 443 default ssl;      server_name domain.com *.domain.com;     root        /var/www/frontend/web;     index       index.php;      location / {         # redirect isn't real file index.php         try_files $uri $uri/ /index.php?$args;     }      location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {         try_files $uri =404;     }     error_page 404 /404.html;      location ~ \.php$ {         include fastcgi_params;         fastcgi_param script_filename $document_root/$fastcgi_script_name;         #fastcgi_pass   127.0.0.1:9000;         fastcgi_pass unix:/var/run/php5-fpm.sock;         try_files $uri =404;     }      location ~ /\.(ht|svn|git) {         deny all;     } }    server {        listen         80;        server_name    domain.com www.domain.com;        return         301 https://$server_name$request_uri; }  server {     charset utf-8;     client_max_body_size 128m;      listen 80; ## listen ipv4     #listen [::]:80 default_server ipv6only=on; ## listen ipv6      server_name backend.domain.com;     root        /var/www/backend/web;     index       index.php;       location / {         # redirect isn't real file index.php         try_files $uri $uri/ /index.php?$args;     }      location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {         try_files $uri =404;     }     #error_page 404 /404.html;      location ~ \.php$ {         include fastcgi_params;         fastcgi_param script_filename $document_root/$fastcgi_script_name;         fastcgi_pass unix:/var/run/php5-fpm.sock;         try_files $uri =404;     }      location ~ /\.(ht|svn|git) {         deny all;     } } 


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -