0

I want that certain pages to be available on https but not on http. I have a Code Igniter framework there.

Here is the code from nginx conf:

server { listen 80; ...... #enforce https if ($request_uri ~ "^(winkelmandje|(index.php/)?winkelmandje|(index.php/)?history|(index.php/)?mobile/winkelmandje|(index.php/)?winkelmandje/voegtoe)"){ rewrite ^/(.*)$ https://$http_host/$1 permanent; } .... } server { listen 443; ssl on; .... #enforce http if ($request_uri ~ "^(!(index.php/)?winkelmandje|!(index.php/)!mobile/winkelmandje|!(index.php/)?history|assets/|!lib_desktop/|!lib_mobile/|!images/|!widget/|!(index.php/)?winkelmandje/voegtoe)"){ rewrite ^/(.*)$ http://$http_host/$1 permanent; } ..... } 

if i go to my domain/winkelmandje (this page is the cart) on http i do not get redirected to https.

Another example is if i access the domain index on https i do not get redirected on http

4
  • You're unlikely to achieve your security goals that way. Why do you want any pages to not use SSL? Commented Feb 14, 2014 at 8:36
  • Well i want only the basket, secure checkout and order history to be on https. The rest of the pages must be on http Commented Feb 14, 2014 at 9:35
  • 1
    I asked why. The reason I ask is that I suspect you're worried about the SSL overhead. The overhead is tiny and not worth worrying about. But if you share session cookies between the SSL and non-SSL parts of the site then anyone who can see the non-SSL traffic can just log in as that user using their cookie. So if you don't have the secure attribute in your cookies, you might as well not bother having SSL at all. If you want security, make the whole site SSL. Commented Feb 14, 2014 at 11:02
  • I made it work! I removed the ! in the ssl and removed the ^ from http and https (because request_uri contains the domain as well). Commented Feb 14, 2014 at 12:28

1 Answer 1

1

Remove the ! in the https server directive and remove the ^ from http and https (because request_uri contains the domain as well).

server { listen 80; ...... #enforce https if ($request_uri ~ "(winkelmandje|(index.php/)?winkelmandje|(index.php/)?history|(index.php/)?mobile/winkelmandje|(index.php/)?winkelmandje/voegtoe)"){ rewrite ^/(.*)$ https://$http_host/$1 permanent; } .... } server { listen 443; ssl on; .... #enforce http if ($request_uri ~ "(!(index.php/)?winkelmandje|!(index.php/)!mobile/winkelmandje|!(index.php/)?history|assets/|!lib_desktop/|!lib_mobile/|!images/|!widget/|!(index.php/)?winkelmandje/voegtoe)"){ rewrite ^/(.*)$ http://$http_host/$1 permanent; } ..... } 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.