My public website https://www.chameth.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nginx.conf 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. user nginx;
  2. worker_processes 1;
  3. error_log /var/log/nginx/error.log warn;
  4. pid /var/run/nginx.pid;
  5. events {
  6. worker_connections 1024;
  7. }
  8. http {
  9. include /etc/nginx/mime.types;
  10. default_type application/octet-stream;
  11. map $http_x_forwarded_for $forwarded_anon {
  12. ~(?P<ip>\d+\.\d+\.\d+)\. $ip.0;
  13. ~(?P<ip>[^:]+:[^:]+): $ip::;
  14. default 0.0.0.0;
  15. }
  16. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  17. '$status $body_bytes_sent "$http_referer" '
  18. '"$http_user_agent" "$forwarded_anon"';
  19. access_log /logs/access.log main;
  20. sendfile on;
  21. keepalive_timeout 65;
  22. server_tokens off;
  23. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
  24. add_header Content-Security-Policy "require-sri-for script; default-src 'none'; img-src 'self' https://photos.chameth.com https://a.c5h.io; style-src 'self'; font-src 'self'; frame-ancestors 'none'; frame-src https://contact.chameth.com; form-action 'none'; base-uri 'none';";
  25. add_header X-Frame-Options "SAMEORIGIN";
  26. add_header X-Content-Type-Options "nosniff";
  27. add_header X-XSS-Protection "1; mode=block";
  28. add_header Expect-CT "enforce; max-age=3600";
  29. add_header Referrer-Policy "no-referrer";
  30. gzip on;
  31. gzip_vary on;
  32. gzip_proxied any;
  33. gzip_comp_level 6;
  34. gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  35. map $http_accept $webp_suffix {
  36. "~*webp" ".webp";
  37. }
  38. map $request_uri $redirect_uri {
  39. /res/images/sense/sense.jpg /2016/04/10/sense-api/sense.jpg;
  40. /res/images/wemo/switch.jpg /2016/05/02/monitoring-power-with-wemo/switch.jpg;
  41. /res/images/wemo/desk-1d.png /2016/05/02/monitoring-power-with-wemo/desk-1d.png;
  42. /res/images/wemo/desk-1w.png /2016/05/02/monitoring-power-with-wemo/desk-1w.png;
  43. /res/images/docker/logo.png /2016/05/21/docker-automatic-nginx-proxy/logo.png;
  44. /res/images/docker/reverse-proxy.png /2016/05/21/docker-automatic-nginx-proxy/reverse-proxy.png;
  45. /res/images/https/https-everywhere.jpg /2016/06/17/why-you-should-be-using-https/https-everywhere.jpg;
  46. /res/images/yubikey/keys.png /2016/08/11/offline-gnupg-master-yubikey-subkeys/keys.png;
  47. /res/images/yubikey/wisdom_of_the_ancients.png /2016/08/11/offline-gnupg-master-yubikey-subkeys/wisdom_of_the_ancients.png;
  48. /res/images/ssh/openssh.png /2016/10/18/shoring-up-sshd/openssh.png;
  49. /res/images/ssh/ssh-audit-github.png /2016/10/18/shoring-up-sshd/ssh-audit-github.png;
  50. /res/images/android-tests/spoon.png /2017/05/16/android-tests-espresso-spoon/spoon.png;
  51. /res/images/android-tests/spoon-espresso.png /2017/05/16/android-tests-espresso-spoon/spoon-espresso.png;
  52. /res/images/dns/providers.png /2017/08/16/top-sites-dns-providers/providers.png;
  53. /res/images/dns/provider-pairings.png /2017/08/16/top-sites-dns-providers/provider-pairings.png;
  54. /res/images/dns/resilience.png /2017/08/16/top-sites-dns-providers/resilience.png;
  55. /res/images/erl/edgerouter.jpg /2017/12/17/dns-over-tls-on-edgerouter-lite/edgerouter.jpg;
  56. /res/images/aoc/advent-of-code.png /2018/12/09/over-the-top-optimisations-in-nim/advent-of-code.png;
  57. /res/images/nim/logo.jpg /2018/12/09/over-the-top-optimisations-in-nim/logo.jpg;
  58. /res/images/debugging/strace.png /2019/05/08/debugging-beyond-the-debugger/strace.png;
  59. /res/images/unsplash/tools.jpg /2019/05/08/debugging-beyond-the-debugger/tools.jpg;
  60. /res/images/obfuscation/kotlin-proguard.png /2019/10/21/obfuscating-kotlin-proguard/kotlin-proguard.png;
  61. /res/images/obfuscation/obfuscated.png /2019/10/21/obfuscating-kotlin-proguard/obfuscated.png;
  62. }
  63. server {
  64. listen 80;
  65. server_name chameth.com localhost;
  66. if ( $redirect_uri ) {
  67. return 301 $redirect_uri;
  68. }
  69. location / {
  70. root /usr/share/nginx/html;
  71. index index.html index.htm;
  72. location /res {
  73. expires 1y;
  74. }
  75. location ~ \.(png|jpe?g)$ {
  76. try_files $uri$webp_suffix $uri =404;
  77. expires 1y;
  78. }
  79. }
  80. error_page 500 502 503 504 /50x.html;
  81. location = /50x.html {
  82. root /usr/share/nginx/html;
  83. }
  84. }
  85. server {
  86. server_name _;
  87. listen 80 default_server;
  88. return 301 https://chameth.com$request_uri;
  89. }
  90. }