Advertisement
Guest User

Untitled

a guest
Apr 4th, 2022
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.34 KB | None | 0 0
  1.  
  2. #user http;
  3. worker_processes 1;
  4.  
  5. #error_log logs/error.log;
  6. #error_log logs/error.log notice;
  7. #error_log logs/error.log info;
  8.  
  9. #pid logs/nginx.pid;
  10.  
  11.  
  12. events {
  13. worker_connections 1024;
  14. }
  15.  
  16.  
  17. http {
  18. include mime.types;
  19. default_type application/octet-stream;
  20.  
  21. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  22. # '$status $body_bytes_sent "$http_referer" '
  23. # '"$http_user_agent" "$http_x_forwarded_for"';
  24.  
  25. #access_log logs/access.log main;
  26.  
  27. sendfile on;
  28. #tcp_nopush on;
  29.  
  30. #keepalive_timeout 0;
  31. keepalive_timeout 65;
  32.  
  33. #gzip on;
  34.  
  35. server {
  36. server_name backend.atavismxi.com;
  37.  
  38. #charset koi8-r;
  39.  
  40. #access_log logs/host.access.log main;
  41.  
  42. location / {
  43. proxy_pass http://localhost:7890/;
  44. }
  45.  
  46. #error_page 404 /404.html;
  47.  
  48. # redirect server error pages to the static page /50x.html
  49. #
  50. error_page 500 502 503 504 /50x.html;
  51. location = /50x.html {
  52. root /usr/share/nginx/html;
  53. }
  54.  
  55. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  56. #
  57. #location ~ \.php$ {
  58. # proxy_pass http://127.0.0.1;
  59. #}
  60.  
  61. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  62. #
  63. #location ~ \.php$ {
  64. # root html;
  65. # fastcgi_pass 127.0.0.1:9000;
  66. # fastcgi_index index.php;
  67. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  68. # include fastcgi_params;
  69. #}
  70.  
  71. # deny access to .htaccess files, if Apache's document root
  72. # concurs with nginx's one
  73. #
  74. #location ~ /\.ht {
  75. # deny all;
  76. #}
  77.  
  78. listen 443 ssl; # managed by Certbot
  79. ssl_certificate /etc/letsencrypt/live/backend.atavismxi.com/fullchain.pem; # managed by Certbot
  80. ssl_certificate_key /etc/letsencrypt/live/backend.atavismxi.com/privkey.pem; # managed by Certbot
  81. include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  82. ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  83.  
  84. }
  85.  
  86. # upstream php-handler {
  87. # server 127.0.0.1:9000;
  88. # server unix:/var/run/php/php7.4-fpm.sock;
  89. # }
  90.  
  91. # Set the `immutable` cache control options only for assets with a cache busting `v` argument
  92. map $arg_v $asset_immutable {
  93. "" "";
  94. default "immutable";
  95. }
  96.  
  97. server {
  98. listen 80;
  99. listen [::]:80;
  100. server_name cloud.atavismxi.com;
  101.  
  102. # Enforce HTTPS
  103. return 301 https://$server_name$request_uri;
  104. }
  105.  
  106. server {
  107. listen [::]:443 ssl; # managed by Certbot
  108. listen 443 ssl; # managed by Certbot
  109. ssl_certificate /etc/letsencrypt/live/cloud.atavismxi.com/fullchain.pem; # managed by Certbot
  110. ssl_certificate_key /etc/letsencrypt/live/cloud.atavismxi.com/privkey.pem; # managed by Certbot
  111. include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  112. ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  113.  
  114. # Path to the root of your installation
  115. root /usr/share/webapps/nextcloud/;
  116.  
  117. server_name cloud.atavismxi.com;
  118.  
  119. # HSTS settings
  120. # WARNING: Only add the preload option once you read about
  121. # the consequences in https://hstspreload.org/. This option
  122. # will add the domain to a hardcoded list that is shipped
  123. # in all major browsers and getting removed from this list
  124. # could take several months.
  125. #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
  126.  
  127. # set max upload size and increase upload timeout:
  128. client_max_body_size 0;
  129. client_body_timeout 300s;
  130. fastcgi_buffers 64 4K;
  131.  
  132. proxy_buffering off;
  133. proxy_request_buffering off;
  134. proxy_read_timeout 30m;
  135. fastcgi_read_timeout 30m;
  136. proxy_max_temp_file_size 0;
  137.  
  138. # Enable gzip but do not remove ETag headers
  139. gzip on;
  140. gzip_vary on;
  141. gzip_comp_level 4;
  142. gzip_min_length 256;
  143. gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
  144. gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
  145.  
  146. # Pagespeed is not supported by Nextcloud, so if your server is built
  147. # with the `ngx_pagespeed` module, uncomment this line to disable it.
  148. #pagespeed off;
  149.  
  150. # HTTP response headers borrowed from Nextcloud `.htaccess`
  151. add_header Referrer-Policy "no-referrer" always;
  152. add_header X-Content-Type-Options "nosniff" always;
  153. add_header X-Download-Options "noopen" always;
  154. add_header X-Frame-Options "SAMEORIGIN" always;
  155. add_header X-Permitted-Cross-Domain-Policies "none" always;
  156. add_header X-Robots-Tag "none" always;
  157. add_header X-XSS-Protection "1; mode=block" always;
  158.  
  159. # Remove X-Powered-By, which is an information leak
  160. fastcgi_hide_header X-Powered-By;
  161.  
  162. # Specify how to handle directories -- specifying `/index.php$request_uri`
  163. # here as the fallback means that Nginx always exhibits the desired behaviour
  164. # when a client requests a path that corresponds to a directory that exists
  165. # on the server. In particular, if that directory contains an index.php file,
  166. # that file is correctly served; if it doesn't, then the request is passed to
  167. # the front-end controller. This consistent behaviour means that we don't need
  168. # to specify custom rules for certain paths (e.g. images and other assets,
  169. # `/updater`, `/ocm-provider`, `/ocs-provider`), and thus
  170. # `try_files $uri $uri/ /index.php$request_uri`
  171. # always provides the desired behaviour.
  172. index index.php index.html /index.php$request_uri;
  173.  
  174. # Rule borrowed from `.htaccess` to handle Microsoft DAV clients
  175. location = / {
  176. if ( $http_user_agent ~ ^DavClnt ) {
  177. return 302 /remote.php/webdav/$is_args$args;
  178. }
  179. }
  180.  
  181. location = /robots.txt {
  182. allow all;
  183. log_not_found off;
  184. access_log off;
  185. }
  186.  
  187. # Make a regex exception for `/.well-known` so that clients can still
  188. # access it despite the existence of the regex rule
  189. # `location ~ /(\.|autotest|...)` which would otherwise handle requests
  190. # for `/.well-known`.
  191. location ^~ /.well-known {
  192. # The rules in this block are an adaptation of the rules
  193. # in `.htaccess` that concern `/.well-known`.
  194.  
  195. location = /.well-known/carddav { return 301 /remote.php/dav/; }
  196. location = /.well-known/caldav { return 301 /remote.php/dav/; }
  197.  
  198. location /.well-known/acme-challenge { try_files $uri $uri/ =404; }
  199. location /.well-known/pki-validation { try_files $uri $uri/ =404; }
  200.  
  201. # Let Nextcloud's API for `/.well-known` URIs handle all other
  202. # requests by passing them to the front-end controller.
  203. return 301 /index.php$request_uri;
  204. }
  205.  
  206. # Rules borrowed from `.htaccess` to hide certain paths from clients
  207. location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; }
  208. location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; }
  209.  
  210. # Ensure this block, which passes PHP files to the PHP process, is above the blocks
  211. # which handle static assets (as seen below). If this block is not declared first,
  212. # then Nginx will encounter an infinite rewriting loop when it prepends `/index.php`
  213. # to the URI, resulting in a HTTP 500 error response.
  214. location ~ \.php(?:$|/) {
  215. include uwsgi_params;
  216. uwsgi_modifier1 14;
  217. # Avoid duplicate headers confusing OC checks
  218. uwsgi_hide_header X-Frame-Options;
  219. uwsgi_hide_header X-XSS-Protection;
  220. uwsgi_hide_header X-Content-Type-Options;
  221. uwsgi_hide_header X-Robots-Tag;
  222. uwsgi_hide_header X-Download-Options;
  223. uwsgi_hide_header X-Permitted-Cross-Domain-Policies;
  224. uwsgi_pass unix:/run/uwsgi/nextcloud.sock;
  225. }
  226.  
  227. location ~ \.(?:css|js|svg|gif|png|jpg|ico|wasm|tflite|map)$ {
  228. try_files $uri /index.php$request_uri;
  229. add_header Cache-Control "public, max-age=15778463, $asset_immutable";
  230. access_log off; # Optional: Don't log access to assets
  231.  
  232. location ~ \.wasm$ {
  233. default_type application/wasm;
  234. }
  235. }
  236.  
  237. location ~ \.woff2?$ {
  238. try_files $uri /index.php$request_uri;
  239. expires 7d; # Cache-Control policy borrowed from `.htaccess`
  240. access_log off; # Optional: Don't log access to assets
  241. }
  242.  
  243. # Rule borrowed from `.htaccess`
  244. location /remote {
  245. return 301 /remote.php$request_uri;
  246. }
  247.  
  248. location / {
  249. try_files $uri $uri/ /index.php$request_uri;
  250. }
  251.  
  252. }
  253.  
  254. # another virtual host using mix of IP-, name-, and port-based configuration
  255. #
  256. #server {
  257. # listen 8000;
  258. # listen somename:8080;
  259. # server_name somename alias another.alias;
  260.  
  261. # location / {
  262. # root html;
  263. # index index.html index.htm;
  264. # }
  265. #}
  266.  
  267.  
  268. # HTTPS server
  269. #
  270. #server {
  271. # listen 443 ssl;
  272. # server_name localhost;
  273.  
  274. # ssl_certificate cert.pem;
  275. # ssl_certificate_key cert.key;
  276.  
  277. # ssl_session_cache shared:SSL:1m;
  278. # ssl_session_timeout 5m;
  279.  
  280. # ssl_ciphers HIGH:!aNULL:!MD5;
  281. # ssl_prefer_server_ciphers on;
  282.  
  283. # location / {
  284. # root html;
  285. # index index.html index.htm;
  286. # }
  287. #}
  288.  
  289.  
  290.  
  291. server {
  292. if ($host = backend.atavismxi.com) {
  293. return 301 https://$host$request_uri;
  294. } # managed by Certbot
  295.  
  296.  
  297. listen 80;
  298. server_name backend.atavismxi.com;
  299. return 404; # managed by Certbot
  300.  
  301.  
  302. }
  303.  
  304. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement