Submitted by LeGiangAnh on Sat, 12/12/2015 - 22:59 Pro Licensee
Hi,
I'm trying to host my Joomla 3.4 website in virtualmin server by nginx. I'm using SSL as default for my self and want to redirect http to https.
Here is my config file in /etc/nginx/sites-available
server {
server_name jplay.tv;
listen 10.0.0.5;
return 301 https://$host$request_uri;
server_name_in_redirect off;
root /home/jplay/public_html;
index index.php index.html index.htm default.html default.htm;
access_log /var/log/virtualmin/jplay.tv_access_log;
error_log /var/log/virtualmin/jplay.tv_error_log;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME /home/jplay/public_html$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT /home/jplay/public_html;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https;
location / {
expires 1d;
# Enable joomla SEF URL's inside Nginx
try_files $uri $uri/ /index.php?$args;
}
# deny running scripts inside writable directories
location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
return 403;
error_page 403 /403_error.html;
}
location ~ \.php$ {
fastcgi_pass unix:/var/php-nginx/143979903845399.sock/socket;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
# caching of files
location ~* \.(ico|pdf|flv)$ {
expires 1y;
}
location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
expires 14d;
}
# ssl on;
listen 10.0.0.5:443 default_server ssl;
fastcgi_read_timeout 120;
ssl_certificate /home/jplay/ssl.cert;
ssl_certificate_key /home/jplay/ssl.key;
}
10.0.0.5 is the private IP, I changed to public IP 137.116.153.17 or 80 but it didn't work. It always show:
This webpage has a redirect loop
ERR_TOO_MANY_REDIRECTS
Port config: http://screencast.com/t/LqZTVDDY
Status:
Active
Comments
Submitted by JamieCameron on Sun, 12/13/2015 - 12:27 Comment #1
Maybe you need a separate
server
block for the http and https ports?That seems to be the recommended solution : http://serverfault.com/questions/67316/in-nginx-how-can-i-rewrite-all-ht...
Submitted by LeGiangAnh on Sun, 12/13/2015 - 20:48 Pro Licensee Comment #2
It works correctly when I use 2 separate blocks. Thank you.