Guest User

nginx.conf

a guest
Nov 10th, 2025
588
0
Never
12
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.70 KB | None | 0 0
  1. nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  2. nginx: configuration file /etc/nginx/nginx.conf test is successful
  3. # configuration file /etc/nginx/nginx.conf:
  4.  
  5. #
  6. # TrueNAS nginx configuration file
  7. #
  8. load_module modules/ngx_http_uploadprogress_module.so;
  9. user www-data www-data;
  10. worker_processes 1;
  11.  
  12. events {
  13. worker_connections 1024;
  14. }
  15.  
  16. http {
  17. include mime.types;
  18. default_type application/octet-stream;
  19. # We need this because TNC domain exceeds 64
  20. server_names_hash_bucket_size 128;
  21.  
  22. # Types to enable gzip compression on
  23. gzip_types
  24. text/plain
  25. text/css
  26. text/js
  27. text/xml
  28. text/javascript
  29. application/javascript
  30. application/x-javascript
  31. application/json
  32. application/xml
  33. application/rss+xml
  34. image/svg+xml;
  35.  
  36. # reserve 1MB under the name 'proxied' to track uploads
  37. upload_progress proxied 1m;
  38.  
  39. sendfile on;
  40. #tcp_nopush on;
  41. client_max_body_size 1000m;
  42.  
  43. #keepalive_timeout 0;
  44. keepalive_timeout 65;
  45.  
  46. # Disable tokens for security (#23684)
  47. server_tokens off;
  48.  
  49.  
  50. gzip on;
  51.  
  52. access_log /var/log/nginx/access.log combined buffer=32k flush=5s;
  53. error_log /var/log/nginx/error.log info;
  54. error_log /var/log/nginx/error.log error;
  55.  
  56. map $http_upgrade $connection_upgrade {
  57. default upgrade;
  58. '' close;
  59. }
  60.  
  61. map $http_origin $allow_origin {
  62. ~^https://web.truenasconnect.net$ $http_origin;
  63. default "";
  64. }
  65.  
  66.  
  67. server {
  68. server_name localhost;
  69. listen 192.168.50.7:444 default_server ssl http2;
  70. listen [::]:444 default_server ssl http2;
  71.  
  72. ssl_certificate "/etc/certificates/cert.crt";
  73. ssl_certificate_key "/etc/certificates/cert.key";
  74. ssl_dhparam "/data/dhparam.pem";
  75. ssl_session_timeout 120m;
  76. ssl_session_cache shared:ssl:16m;
  77. ssl_protocols TLSv1.2 TLSv1.3;
  78. ssl_prefer_server_ciphers on;
  79. ssl_ciphers EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA:EDH+aRSA:EECDH:!RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!SHA1:!SHA256:!SHA384;
  80.  
  81. #resolver ;
  82. #ssl_trusted_certificate ;
  83.  
  84.  
  85.  
  86.  
  87. # Security Headers
  88. add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
  89. add_header X-Content-Type-Options "nosniff" always;
  90. add_header X-XSS-Protection "1; mode=block" always;
  91. add_header Permissions-Policy "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()" always;
  92. add_header Referrer-Policy "strict-origin" always;
  93. add_header X-Frame-Options "SAMEORIGIN" always;
  94.  
  95. location / {
  96. allow all;
  97. rewrite ^.* $scheme://$http_host/ui/ redirect;
  98. }
  99. location /vm/display/3 {
  100. proxy_pass http://192.168.50.7:5901/;
  101. proxy_http_version 1.1;
  102. proxy_set_header X-Real-Remote-Addr $remote_addr;
  103. proxy_set_header X-Real-Remote-Port $remote_port;
  104. proxy_set_header X-Https $https;
  105. proxy_set_header X-Forwarded-For $remote_addr;
  106. proxy_set_header Upgrade $http_upgrade;
  107. proxy_set_header Connection $connection_upgrade;
  108. }
  109. location /progress {
  110. # report uploads tracked in the 'proxied' zone
  111. report_uploads proxied;
  112. }
  113.  
  114. location /api {
  115. allow all; # This is handled by `Middleware.ws_can_access` because if we return HTTP 403, browser security
  116. # won't allow us to understand that connection error was due to client IP not being allowlisted.
  117. proxy_pass http://127.0.0.1:6000/api;
  118. proxy_http_version 1.1;
  119. proxy_set_header X-Real-Remote-Addr $remote_addr;
  120. proxy_set_header X-Real-Remote-Port $remote_port;
  121. proxy_set_header X-Https $https;
  122. proxy_set_header Upgrade $http_upgrade;
  123. proxy_set_header Connection "upgrade";
  124. }
  125.  
  126. location ~ ^/api/docs/?$ {
  127. rewrite .* /api/docs/current redirect;
  128. }
  129.  
  130. location /api/docs {
  131. alias /usr/share/middlewared/docs;
  132. add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
  133. add_header Expires 0;
  134. }
  135.  
  136. location /api/docs/current {
  137. alias /usr/share/middlewared/docs/v25.10.0;
  138. add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
  139. add_header Expires 0;
  140. }
  141.  
  142. location @index {
  143. add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
  144. add_header Expires 0;
  145.  
  146.  
  147. # Security Headers
  148. add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
  149. add_header X-Content-Type-Options "nosniff" always;
  150. add_header X-XSS-Protection "1; mode=block" always;
  151. add_header Permissions-Policy "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()" always;
  152. add_header Referrer-Policy "strict-origin" always;
  153. add_header X-Frame-Options "SAMEORIGIN" always;
  154.  
  155. root /usr/share/truenas/webui;
  156. try_files /index.html =404;
  157. }
  158.  
  159. location = /ui/ {
  160. allow all;
  161. add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
  162. add_header Expires 0;
  163.  
  164.  
  165. # Security Headers
  166. add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
  167. add_header X-Content-Type-Options "nosniff" always;
  168. add_header X-XSS-Protection "1; mode=block" always;
  169. add_header Permissions-Policy "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()" always;
  170. add_header Referrer-Policy "strict-origin" always;
  171. add_header X-Frame-Options "SAMEORIGIN" always;
  172.  
  173. root /usr/share/truenas/webui;
  174. try_files /index.html =404;
  175. }
  176.  
  177. location /ui {
  178. allow all;
  179.  
  180. # `allow`/`deny` are not allowed in `if` blocks so we'll have to make that check in the middleware itself.
  181. proxy_set_header X-Real-Remote-Addr $remote_addr;
  182. proxy_set_header X-Https $https;
  183.  
  184. add_header Cache-Control "must-revalidate";
  185. add_header Etag "TrueNAS-25.10.0";
  186.  
  187.  
  188. # Security Headers
  189. add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
  190. add_header X-Content-Type-Options "nosniff" always;
  191. add_header X-XSS-Protection "1; mode=block" always;
  192. add_header Permissions-Policy "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()" always;
  193. add_header Referrer-Policy "strict-origin" always;
  194. add_header X-Frame-Options "SAMEORIGIN" always;
  195.  
  196.  
  197. alias /usr/share/truenas/webui;
  198. try_files $uri $uri/ @index;
  199. }
  200.  
  201. location /websocket {
  202. allow all; # This is handled by `Middleware.ws_can_access` because if we return HTTP 403, browser security
  203. # won't allow us to understand that connection error was due to client IP not being allowlisted.
  204. proxy_pass http://127.0.0.1:6000/websocket;
  205. proxy_http_version 1.1;
  206. proxy_set_header X-Real-Remote-Addr $remote_addr;
  207. proxy_set_header X-Real-Remote-Port $remote_port;
  208. proxy_set_header X-Https $https;
  209. proxy_set_header Upgrade $http_upgrade;
  210. proxy_set_header Connection "upgrade";
  211. }
  212.  
  213. location /websocket/shell {
  214. allow all; # This is handled by `Middleware.ws_can_access` because if we return HTTP 403, browser security
  215. # won't allow us to understand that connection error was due to client IP not being allowlisted.
  216. proxy_pass http://127.0.0.1:6000/_shell;
  217. proxy_http_version 1.1;
  218. proxy_set_header X-Real-Remote-Addr $remote_addr;
  219. proxy_set_header X-Real-Remote-Port $remote_port;
  220. proxy_set_header X-Https $https;
  221. proxy_set_header Upgrade $http_upgrade;
  222. proxy_set_header Connection "upgrade";
  223. proxy_send_timeout 7d;
  224. proxy_read_timeout 7d;
  225. }
  226.  
  227. location /api/v2.0 {
  228. # do not add the path to proxy_pass because of automatic url decoding
  229. # e.g. /api/v2.0/pool/dataset/id/tank%2Ffoo/ would become
  230. # /api/v2.0/pool/dataset/id/tank/foo/
  231. proxy_pass http://127.0.0.1:6000;
  232. proxy_http_version 1.1;
  233. proxy_set_header X-Real-Remote-Addr $remote_addr;
  234. proxy_set_header X-Real-Remote-Port $remote_port;
  235. proxy_set_header X-Https $https;
  236. proxy_set_header Host $host;
  237. proxy_set_header X-Forwarded-For $remote_addr;
  238. proxy_set_header X-Server-Port $server_port;
  239. proxy_set_header X-Scheme $Scheme;
  240. }
  241.  
  242. location /_download {
  243. proxy_pass http://127.0.0.1:6000;
  244. proxy_http_version 1.1;
  245. proxy_set_header X-Real-Remote-Addr $remote_addr;
  246. proxy_set_header X-Real-Remote-Port $remote_port;
  247. proxy_set_header X-Https $https;
  248. proxy_read_timeout 10m;
  249. }
  250.  
  251. location /_upload {
  252. # Allow uploads of any size. Its middlewared job to handle size.
  253. client_max_body_size 0;
  254. proxy_pass http://127.0.0.1:6000;
  255. # make sure nginx does not buffer the upload and pass directly to middlewared
  256. proxy_request_buffering off;
  257. proxy_http_version 1.1;
  258. proxy_set_header X-Real-Remote-Addr $remote_addr;
  259. proxy_set_header X-Real-Remote-Port $remote_port;
  260. proxy_set_header X-Https $https;
  261. }
  262.  
  263. location /_plugins {
  264. proxy_pass http://127.0.0.1:6000/_plugins;
  265. proxy_http_version 1.1;
  266. proxy_set_header X-Real-Remote-Addr $remote_addr;
  267. proxy_set_header X-Real-Remote-Port $remote_port;
  268. proxy_set_header X-Https $https;
  269. proxy_set_header Host $host;
  270. proxy_set_header X-Forwarded-For $remote_addr;
  271. }
  272. }
  273.  
  274. server {
  275. listen 192.168.50.7:81;
  276. listen [::]:81;
  277. server_name localhost;
  278. return 307 https://$host:444$request_uri;
  279. }
  280.  
  281. #server {
  282. #listen 80; # NGINX listens on port 80 for incoming requests
  283. #server_name home.sommnas.org;
  284. #error_log /var/log/homeassistant.log debug;
  285.  
  286. #location / {
  287. #proxy_pass http://192.168.50.33:8123/; # Forward requests to the backend on port 8123
  288. #proxy_set_header Host $host;
  289. #proxy_read_timeout 30;
  290. #proxy_buffering off;
  291. # proxy_set_header X-Real-IP $remote_addr;
  292. # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  293. # proxy_set_header X-Forwarded-Proto $scheme;
  294. #}
  295.  
  296. server {
  297. listen 443 ssl;
  298. server_name home.sommnas.org;
  299. error_log /var/log/homeassist.log error;
  300. error_log /var/log/homeassist.log info;
  301. error_log /var/log/homeassist.log debug;
  302.  
  303. # SSL configuration (point to your certificate and key)
  304. ssl_certificate "/etc/certificates/cert.crt";
  305. ssl_certificate_key "/etc/certificates/cert.key";
  306.  
  307. location / {
  308. proxy_pass http://192.168.50.33:8123;
  309. proxy_set_header Host $host;
  310. proxy_set_header X-Real-IP $remote_addr;
  311. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  312. proxy_set_header X-Forwarded-Proto $scheme;
  313.  
  314. # WebSocket support
  315. proxy_http_version 1.1;
  316. proxy_set_header Upgrade $http_upgrade;
  317. proxy_set_header Connection "upgrade";
  318. }
  319. }
  320.  
  321. }
  322.  
  323. # configuration file /etc/nginx/mime.types:
  324.  
  325. types {
  326. text/html html htm shtml;
  327. text/css css;
  328. text/xml xml;
  329. image/gif gif;
  330. image/jpeg jpeg jpg;
  331. application/javascript js;
  332. application/atom+xml atom;
  333. application/rss+xml rss;
  334.  
  335. text/mathml mml;
  336. text/plain txt;
  337. text/vnd.sun.j2me.app-descriptor jad;
  338. text/vnd.wap.wml wml;
  339. text/x-component htc;
  340.  
  341. image/avif avif;
  342. image/png png;
  343. image/svg+xml svg svgz;
  344. image/tiff tif tiff;
  345. image/vnd.wap.wbmp wbmp;
  346. image/webp webp;
  347. image/x-icon ico;
  348. image/x-jng jng;
  349. image/x-ms-bmp bmp;
  350.  
  351. font/woff woff;
  352. font/woff2 woff2;
  353.  
  354. application/java-archive jar war ear;
  355. application/json json;
  356. application/mac-binhex40 hqx;
  357. application/msword doc;
  358. application/pdf pdf;
  359. application/postscript ps eps ai;
  360. application/rtf rtf;
  361. application/vnd.apple.mpegurl m3u8;
  362. application/vnd.google-earth.kml+xml kml;
  363. application/vnd.google-earth.kmz kmz;
  364. application/vnd.ms-excel xls;
  365. application/vnd.ms-fontobject eot;
  366. application/vnd.ms-powerpoint ppt;
  367. application/vnd.oasis.opendocument.graphics odg;
  368. application/vnd.oasis.opendocument.presentation odp;
  369. application/vnd.oasis.opendocument.spreadsheet ods;
  370. application/vnd.oasis.opendocument.text odt;
  371. application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
  372. application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
  373. application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
  374. application/vnd.wap.wmlc wmlc;
  375. application/wasm wasm;
  376. application/x-7z-compressed 7z;
  377. application/x-cocoa cco;
  378. application/x-java-archive-diff jardiff;
  379. application/x-java-jnlp-file jnlp;
  380. application/x-makeself run;
  381. application/x-perl pl pm;
  382. application/x-pilot prc pdb;
  383. application/x-rar-compressed rar;
  384. application/x-redhat-package-manager rpm;
  385. application/x-sea sea;
  386. application/x-shockwave-flash swf;
  387. application/x-stuffit sit;
  388. application/x-tcl tcl tk;
  389. application/x-x509-ca-cert der pem crt;
  390. application/x-xpinstall xpi;
  391. application/xhtml+xml xhtml;
  392. application/xspf+xml xspf;
  393. application/zip zip;
  394.  
  395. application/octet-stream bin exe dll;
  396. application/octet-stream deb;
  397. application/octet-stream dmg;
  398. application/octet-stream iso img;
  399. application/octet-stream msi msp msm;
  400.  
  401. audio/midi mid midi kar;
  402. audio/mpeg mp3;
  403. audio/ogg ogg;
  404. audio/x-m4a m4a;
  405. audio/x-realaudio ra;
  406.  
  407. video/3gpp 3gpp 3gp;
  408. video/mp2t ts;
  409. video/mp4 mp4;
  410. video/mpeg mpeg mpg;
  411. video/quicktime mov;
  412. video/webm webm;
  413. video/x-flv flv;
  414. video/x-m4v m4v;
  415. video/x-mng mng;
  416. video/x-ms-asf asx asf;
  417. video/x-ms-wmv wmv;
  418. video/x-msvideo avi;
  419. }
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment