Need help optimizing nginx to redirect from HTTP/80 to HTTPS/443
Igor Sysoev
is at rambler-co.ru
Sun Feb 22 15:35:02 MSK 2009
On Sun, Feb 22, 2009 at 11:55:39AM +0000, Mark Alan 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
?
> 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;
rewrite ^ https://pma.clinicacgm.0/ permanent;
or if you want to preserve URI:
rewrite ^ https://pma.clinicacgm.0$request_uri? 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;
You do not need "index index.php" here as all requests are passed to fastcgi.
> 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 ---
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list