installation-nginx.rst 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. .. _installation nginx:
  2. ==================
  3. Install with nginx
  4. ==================
  5. .. _nginx:
  6. https://docs.nginx.com/nginx/admin-guide/
  7. .. _nginx server configuration:
  8. https://docs.nginx.com/nginx/admin-guide/web-server/web-server/#setting-up-virtual-servers
  9. .. _nginx beginners guide:
  10. http://nginx.org/en/docs/beginners_guide.html
  11. .. _Getting Started wiki:
  12. https://www.nginx.com/resources/wiki/start/
  13. .. contents:: Contents
  14. :depth: 2
  15. :local:
  16. :backlinks: entry
  17. The nginx HTTP server
  18. =====================
  19. If nginx_ is not installed (uwsgi will not work with the package nginx-light)
  20. install it now.
  21. .. tabs::
  22. .. group-tab:: Ubuntu / debian
  23. .. code:: sh
  24. sudo -H apt-get install nginx
  25. .. group-tab:: Arch Linux
  26. .. code-block:: sh
  27. sudo -H pacman -S nginx-mainline
  28. sudo -H systemctl enable nginx
  29. sudo -H systemctl start nginx
  30. .. group-tab:: Fedora / RHEL
  31. .. code-block:: sh
  32. sudo -H dnf install nginx
  33. sudo -H systemctl enable nginx
  34. sudo -H systemctl start nginx
  35. Now at http://localhost you should see a *Welcome to nginx!* page, on Fedora you
  36. see a *Fedora Webserver - Test Page*. The test page comes from the default
  37. `nginx server configuration`_:
  38. .. tabs::
  39. .. group-tab:: Ubuntu / debian
  40. .. code:: sh
  41. less /etc/nginx/nginx.conf
  42. there is a line including site configurations from:
  43. .. code:: nginx
  44. include /etc/nginx/sites-enabled/*;
  45. .. group-tab:: Arch Linux
  46. .. code-block:: sh
  47. less /etc/nginx/nginx.conf
  48. in there is a configuration section named ``server``:
  49. .. code-block:: nginx
  50. server {
  51. listen 80;
  52. server_name localhost;
  53. # ...
  54. }
  55. .. group-tab:: Fedora / RHEL
  56. .. code-block:: sh
  57. less /etc/nginx/nginx.conf
  58. there is a line including site configurations from:
  59. .. code:: nginx
  60. include /etc/nginx/conf.d/*.conf;
  61. .. _nginx searx site:
  62. A searx site
  63. ============
  64. .. sidebar:: public to the internet?
  65. If your searx instance is public, stop here and first install :ref:`filtron
  66. reverse proxy <filtron.sh>` and :ref:`result proxy morty <morty.sh>`, see
  67. :ref:`installation scripts`.
  68. Now you have to create a configuration for the searx site. If nginx_ is new to
  69. you, the `nginx beginners guide`_ is a good starting point and the `Getting
  70. Started wiki`_ is always a good resource *to keep in the pocket*.
  71. .. tabs::
  72. .. group-tab:: Ubuntu / debian
  73. Create configuration at ``/etc/nginx/sites-available/searx`` and place a
  74. symlink to sites-enabled:
  75. .. code:: sh
  76. sudo -H ln -s /etc/nginx/sites-available/searx /etc/nginx/sites-enabled/searx
  77. .. group-tab:: Arch Linux
  78. In the ``/etc/nginx/nginx.conf`` file, replace the configuration section
  79. named ``server``.
  80. .. group-tab:: Fedora / RHEL
  81. Create configuration at ``/etc/nginx/conf.d/searx`` and place a
  82. symlink to sites-enabled:
  83. .. tabs::
  84. .. group-tab:: filtron at ``/`` & ``/morty``
  85. Use this setup, if your instance is public to the internet:
  86. .. code:: nginx
  87. location / {
  88. proxy_set_header Host $http_host;
  89. proxy_set_header X-Real-IP $remote_addr;
  90. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  91. proxy_set_header X-Scheme $scheme;
  92. proxy_pass http://127.0.0.1:4004/;
  93. }
  94. .. code:: nginx
  95. location /morty {
  96. proxy_set_header Host $http_host;
  97. proxy_set_header X-Real-IP $remote_addr;
  98. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  99. proxy_set_header X-Scheme $scheme;
  100. proxy_pass http://127.0.0.1:3000/;
  101. }
  102. For a fully result proxification add :ref:`morty's <searx_morty>` public
  103. URL to your :origin:`searx/settings.yml`:
  104. .. code:: yaml
  105. result_proxy:
  106. # replace searx.example.com with your server's public name
  107. url : http://searx.example.com/
  108. .. group-tab:: searx at ``/``
  109. Use this setup only, if your instance is **NOT** public to the internet:
  110. .. code:: nginx
  111. server {
  112. listen 80;
  113. listen [::]:80;
  114. # replace searx.example.com with your server's public name
  115. server_name searx.example.com;
  116. root /usr/local/searx/searx;
  117. location /static {
  118. }
  119. location / {
  120. include uwsgi_params;
  121. uwsgi_pass unix:/run/uwsgi/app/searx/socket;
  122. }
  123. }
  124. .. group-tab:: searx at ``/searx``
  125. Use this setup only, if your instance is **NOT** public to the internet:
  126. .. code:: nginx
  127. location /searx/static {
  128. alias /usr/local/searx/searx/static;
  129. }
  130. location /searx {
  131. uwsgi_param SCRIPT_NAME /searx;
  132. include uwsgi_params;
  133. uwsgi_pass unix:/run/uwsgi/app/searx/socket;
  134. }
  135. **OR** using reverse proxy. Please, note that reverse proxy advised to be
  136. used in case of single-user or low-traffic instances.
  137. .. code:: nginx
  138. location /searx/static {
  139. alias /usr/local/searx/searx/static;
  140. }
  141. location /searx {
  142. proxy_pass http://127.0.0.1:8888;
  143. proxy_set_header Host $host;
  144. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  145. proxy_set_header X-Scheme $scheme;
  146. proxy_set_header X-Script-Name /searx;
  147. proxy_buffering off;
  148. }
  149. Enable ``base_url`` in :origin:`searx/settings.yml`
  150. .. code:: yaml
  151. server:
  152. # replace searx.example.com with your server's public name
  153. base_url : http://searx.example.com/searx/
  154. Restart service:
  155. .. tabs::
  156. .. group-tab:: Ubuntu / debian
  157. .. code:: sh
  158. sudo -H systemctl restart nginx
  159. sudo -H systemctl restart uwsgi
  160. .. group-tab:: Arch Linux
  161. .. code:: sh
  162. sudo -H systemctl restart nginx
  163. sudo -H systemctl restart uwsgi
  164. .. group-tab:: Fedora
  165. .. code:: sh
  166. sudo -H systemctl restart nginx
  167. sudo -H systemctl restart uwsgi
  168. Disable logs
  169. ============
  170. For better privacy you can disable nginx logs in ``/etc/nginx/nginx.conf``.
  171. .. code:: nginx
  172. http {
  173. # ...
  174. access_log /dev/null;
  175. error_log /dev/null;
  176. # ...
  177. }