larios
February 22, 2009, 1:09pm
1
I am trying to optimize Nginx (Nginx/0.6.35 + Ubuntu 8.10) to redirect
from HTTP/80 to HTTPS/443
I.e., any calls made to:
http://pma.clinicacgm.0/ ,
should go into:
https://pma.clinicacgm.0/
Could you review the bellow attached script and see if it can be
optimized?
Thank you,
M.
— cut here —
/etc/nginx/sites-available/spma
server {
listen pma.clinicacgm.0:80;
server_name pma.clinicacgm.0;
redirect phpmyadmin to the https page
location / {
# redirect to secure page [permanent | redirect]
rewrite ^/(.*) https://pma.clinicacgm.0 permanent;
}
}
server {
listen pma.clinicacgm.0:443;
server_name pma.clinicacgm.0;
access_log /var/log/nginx/pma.access.log;
error_log /var/log/nginx/pma.error.log;
#root /var/www/phpmyadmin;
root /usr/share/phpmyadmin;
location / {
index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/tmp/php-fastcgi.socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS on;
}
gzip off; # gzipping SSL encripted data is a waste of time
ssl on;
ssl_certificate /etc/nginx/ssl/clinicacgm/server.crt;
ssl_certificate_key /etc/nginx/ssl/clinicacgm/server.key;
}
— cut here —
larios
February 22, 2009, 1:49pm
2
On Sun, Feb 22, 2009 at 11:55:39AM +0000, Mark A. wrote:
I am trying to optimize Nginx (Nginx/0.6.35 + Ubuntu 8.10) to redirect
from HTTP/80 to HTTPS/443
I.e., any calls made to:
http://pma.clinicacgm.0/ ,
should go into:
https://pma.clinicacgm.0/
Do you want to redirect
http://pma.clinicacgm.0/some/uri to just
https://pma.clinicacgm.0/
or to
https://pma.clinicacgm.0/some/uri
?
server {
listen pma.clinicacgm.0:80;
server_name pma.clinicacgm.0;
redirect phpmyadmin to the https page
location / {
# redirect to secure page [permanent | redirect]
rewrite ^/(.*) https://pma.clinicacgm.0 permanent;
rewrite ^ https://pma.clinicacgm.0/ permanent;
or if you want to preserve URI:
rewrite ^ https://pma.clinicacgm.0$request_uri? permanent;
root /usr/share/phpmyadmin;
location / {
index index.php;
You do not need “index index.php” here as all requests are passed to
fastcgi.
larios
February 22, 2009, 3:19pm
3
Igor S. wrote:
Do you want to redirect
http://pma.clinicacgm.0/some/uri to just https://pma.clinicacgm.0/
or to
https://pma.clinicacgm.0/some/uri
Both.
rewrite ^ https://pma.clinicacgm.0/ permanent;
or if you want to preserve URI:
rewrite ^ https://pma.clinicacgm.0$request_uri? permanent;
Thank you. Both work and do their different jobs as intended.
index index.php;
You do not need “index index.php” here as all requests are passed to fastcgi.
You are right. It shouldn’t be there in the first place.
Thank you very much for the fast response.
M.