installation-nginx.rst 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. .. _installation nginx:
  2. ==================
  3. Install with nginx
  4. ==================
  5. .. sidebar:: public HTTP servers
  6. On public searx instances use an application firewall (:ref:`filtron
  7. <filtron.sh>`).
  8. .. contents:: Contents
  9. :depth: 2
  10. :local:
  11. :backlinks: entry
  12. If nginx is not installed (uwsgi will not work with the package
  13. nginx-light):
  14. .. tabs::
  15. .. group-tab:: Ubuntu / debian
  16. .. code:: sh
  17. sudo -H apt-get install nginx
  18. Hosted at ``/``
  19. ===============
  20. Create the configuration file ``/etc/nginx/sites-available/searx`` with this
  21. content:
  22. .. code:: nginx
  23. server {
  24. listen 80;
  25. server_name searx.example.com;
  26. root /usr/local/searx/searx;
  27. location /static {
  28. }
  29. location / {
  30. include uwsgi_params;
  31. uwsgi_pass unix:/run/uwsgi/app/searx/socket;
  32. }
  33. }
  34. Create a symlink to sites-enabled:
  35. .. code:: sh
  36. sudo -H ln -s /etc/nginx/sites-available/searx /etc/nginx/sites-enabled/searx
  37. Restart service:
  38. .. tabs::
  39. .. group-tab:: Ubuntu / debian
  40. .. code:: sh
  41. sudo -H systemctl restart nginx
  42. sudo -H systemctl restart uwsgi
  43. from subdirectory URL (``/searx``)
  44. ==================================
  45. Add this configuration in the server config file
  46. ``/etc/nginx/sites-enabled/default``:
  47. .. code:: nginx
  48. location /searx/static {
  49. alias /usr/local/searx/searx/static;
  50. }
  51. location /searx {
  52. uwsgi_param SCRIPT_NAME /searx;
  53. include uwsgi_params;
  54. uwsgi_pass unix:/run/uwsgi/app/searx/socket;
  55. }
  56. **OR** using reverse proxy (Please, note that reverse proxy advised to be used
  57. in case of single-user or low-traffic instances.)
  58. .. code:: nginx
  59. location /searx/static {
  60. alias /usr/local/searx/searx/static;
  61. }
  62. location /searx {
  63. proxy_pass http://127.0.0.1:8888;
  64. proxy_set_header Host $host;
  65. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  66. proxy_set_header X-Scheme $scheme;
  67. proxy_set_header X-Script-Name /searx;
  68. proxy_buffering off;
  69. }
  70. Enable ``base_url`` in ``searx/settings.yml``
  71. .. code:: yaml
  72. base_url : http://your.domain.tld/searx/
  73. Restart service:
  74. .. tabs::
  75. .. group-tab:: Ubuntu / debian
  76. .. code:: sh
  77. sudo -H systemctl restart nginx
  78. sudo -H systemctl restart uwsgi
  79. disable logs
  80. ============
  81. For better privacy you can disable nginx logs about searx. How to proceed:
  82. below ``uwsgi_pass`` in ``/etc/nginx/sites-available/default`` add:
  83. .. code:: nginx
  84. access_log /dev/null;
  85. error_log /dev/null;
  86. Restart service:
  87. .. tabs::
  88. .. group-tab:: Ubuntu / debian
  89. .. code:: sh
  90. sudo -H systemctl restart nginx