redirect - Strange subdomain issue in NGINX -
what want is:
- to redirect
www.domain.com,domain.comhttps://domain.com - to forward
subdomain.domain.com,domain.comsame directory - to forward
backend.domain.comseperate 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
Post a Comment