meesteridle

Nginx -- https vhost rewrite

Jun 29th, 2015
5,225
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 1.66 KB | None | 0 0
  1. server {
  2.     listen 172.31.18.221:80;
  3.     server_name www.example.info example.info;
  4.     charset utf-8;
  5.     rewrite ^ https://www.example.info$request_uri? permanent;
  6. }
  7. server {
  8.     listen 172.31.18.221:443 ssl;
  9.     server_name www.example.info example.info;
  10.     charset utf-8;
  11.     add_header Strict-Transport-Security max-age=15768000;
  12.     root /var/www/example/w;
  13.     index index.html index.htm;
  14.     error_log /var/log/nginx/example_error.log error;
  15.     access_log /var/log/nginx/example_access.log combined;
  16.  
  17.     if ($host = 'example.info') {
  18.         rewrite ^/(.*)$  https://www.example.info/$1  permanent;
  19.     }
  20.  
  21.     ssl on;
  22.     ssl_certificate example2.pem;
  23.     ssl_certificate_key example2.key;
  24.     ssl_session_cache shared:SSL:50m;
  25.     ssl_session_timeout 5m;
  26.  
  27.     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  28.     ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4"; # Disable weak ciphers
  29.     ssl_prefer_server_ciphers on;
  30.  
  31.     location / {
  32.         index index.php;
  33.         error_page 404 = @mediawiki;
  34.     }
  35.  
  36.     location @mediawiki {
  37.         rewrite ^/wiki([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
  38.     }
  39.  
  40.     location ~ \.php$ {
  41.         fastcgi_split_path_info ^(.+\.php)(/.+)$;
  42.         fastcgi_pass unix:/var/run/php5-fpm.sock;
  43.         fastcgi_index index.php;
  44.         include fastcgi_params;
  45.     }
  46.  
  47.     location ~ /\.ht {
  48.         deny all;
  49.     }
  50. }
Advertisement
Comments
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment