Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.74 KB | None | 0 0
  1. # configuration file /etc/nginx/nginx.conf:
  2. # Generated by nginxconfig.io
  3. # https://nginxconfig.io/?0.domain=mysite.com&0.document_root=%2F&0.non_www=false&0.https=false&0.wordpress&0.access_log_domain&0.error_log_domain&resolver_opendns=false&referrer_policy=origin&server_tokens&limit_req
  4.  
  5. user www-data;
  6. pid /run/nginx.pid;
  7. worker_processes auto;
  8. worker_rlimit_nofile 65535;
  9.  
  10. events {
  11. multi_accept on;
  12. worker_connections 65535;
  13. }
  14.  
  15. http {
  16. charset utf-8;
  17. sendfile on;
  18. tcp_nopush on;
  19. tcp_nodelay on;
  20. log_not_found off;
  21. types_hash_max_size 2048;
  22. client_max_body_size 16M;
  23.  
  24. # MIME
  25. include mime.types;
  26. default_type application/octet-stream;
  27.  
  28. # logging
  29. access_log /var/log/nginx/access.log;
  30. error_log /var/log/nginx/error.log warn;
  31.  
  32. # limits
  33. limit_req_log_level warn;
  34. limit_req_zone $binary_remote_addr zone=login:10m rate=10r/m;
  35.  
  36. # load configs
  37. include /etc/nginx/conf.d/*.conf;
  38. include /etc/nginx/sites-enabled/*;
  39. }
  40.  
  41. # configuration file /etc/nginx/mime.types:
  42.  
  43. types {
  44. text/html html htm shtml;
  45. text/css css;
  46. text/xml xml;
  47. image/gif gif;
  48. image/jpeg jpeg jpg;
  49. application/javascript js;
  50. application/atom+xml atom;
  51. application/rss+xml rss;
  52.  
  53. text/mathml mml;
  54. text/plain txt;
  55. text/vnd.sun.j2me.app-descriptor jad;
  56. text/vnd.wap.wml wml;
  57. text/x-component htc;
  58.  
  59. image/png png;
  60. image/svg+xml svg svgz;
  61. image/tiff tif tiff;
  62. image/vnd.wap.wbmp wbmp;
  63. image/webp webp;
  64. image/x-icon ico;
  65. image/x-jng jng;
  66. image/x-ms-bmp bmp;
  67.  
  68. font/woff woff;
  69. font/woff2 woff2;
  70.  
  71. application/java-archive jar war ear;
  72. application/json json;
  73. application/mac-binhex40 hqx;
  74. application/msword doc;
  75. application/pdf pdf;
  76. application/postscript ps eps ai;
  77. application/rtf rtf;
  78. application/vnd.apple.mpegurl m3u8;
  79. application/vnd.google-earth.kml+xml kml;
  80. application/vnd.google-earth.kmz kmz;
  81. application/vnd.ms-excel xls;
  82. application/vnd.ms-fontobject eot;
  83. application/vnd.ms-powerpoint ppt;
  84. application/vnd.oasis.opendocument.graphics odg;
  85. application/vnd.oasis.opendocument.presentation odp;
  86. application/vnd.oasis.opendocument.spreadsheet ods;
  87. application/vnd.oasis.opendocument.text odt;
  88. application/vnd.openxmlformats-officedocument.presentationml.presentation
  89. pptx;
  90. application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  91. xlsx;
  92. application/vnd.openxmlformats-officedocument.wordprocessingml.document
  93. docx;
  94. application/vnd.wap.wmlc wmlc;
  95. application/x-7z-compressed 7z;
  96. application/x-cocoa cco;
  97. application/x-java-archive-diff jardiff;
  98. application/x-java-jnlp-file jnlp;
  99. application/x-makeself run;
  100. application/x-perl pl pm;
  101. application/x-pilot prc pdb;
  102. application/x-rar-compressed rar;
  103. application/x-redhat-package-manager rpm;
  104. application/x-sea sea;
  105. application/x-shockwave-flash swf;
  106. application/x-stuffit sit;
  107. application/x-tcl tcl tk;
  108. application/x-x509-ca-cert der pem crt;
  109. application/x-xpinstall xpi;
  110. application/xhtml+xml xhtml;
  111. application/xspf+xml xspf;
  112. application/zip zip;
  113.  
  114. application/octet-stream bin exe dll;
  115. application/octet-stream deb;
  116. application/octet-stream dmg;
  117. application/octet-stream iso img;
  118. application/octet-stream msi msp msm;
  119.  
  120. audio/midi mid midi kar;
  121. audio/mpeg mp3;
  122. audio/ogg ogg;
  123. audio/x-m4a m4a;
  124. audio/x-realaudio ra;
  125.  
  126. video/3gpp 3gpp 3gp;
  127. video/mp2t ts;
  128. video/mp4 mp4;
  129. video/mpeg mpeg mpg;
  130. video/quicktime mov;
  131. video/webm webm;
  132. video/x-flv flv;
  133. video/x-m4v m4v;
  134. video/x-mng mng;
  135. video/x-ms-asf asx asf;
  136. video/x-ms-wmv wmv;
  137. video/x-msvideo avi;
  138. }
  139.  
  140. # configuration file /etc/nginx/conf.d/default.conf:
  141. server {
  142. listen 80;
  143. server_name localhost;
  144.  
  145. #charset koi8-r;
  146. #access_log /var/log/nginx/host.access.log main;
  147.  
  148. location / {
  149. root /usr/share/nginx/html;
  150. index index.php index.html index.htm;
  151. }
  152.  
  153. #error_page 404 /404.html;
  154.  
  155. # redirect server error pages to the static page /50x.html
  156. #
  157. error_page 500 502 503 504 /50x.html;
  158. location = /50x.html {
  159. root /usr/share/nginx/html;
  160. }
  161.  
  162. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  163. #
  164. #location ~ \.php$ {
  165. # proxy_pass http://127.0.0.1;
  166. #}
  167.  
  168. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  169. #
  170. #location ~ \.php$ {
  171. # root html;
  172. # fastcgi_pass 127.0.0.1:9000;
  173. # fastcgi_index index.php;
  174. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  175. # include fastcgi_params;
  176. #}
  177.  
  178. # deny access to .htaccess files, if Apache's document root
  179. # concurs with nginx's one
  180. #
  181. #location ~ /\.ht {
  182. # deny all;
  183. #}
  184. }
  185.  
  186.  
  187. # configuration file /etc/nginx/sites-enabled/mysite.com.conf:
  188. server {
  189. listen 80;
  190. listen [::]:80;
  191.  
  192. server_name www.mysite.com;
  193. set $base /var/www/mysite.com;
  194. root $base/;
  195.  
  196. # security
  197. include nginxconfig.io/security.conf;
  198.  
  199. # logging
  200. access_log /var/log/nginx/mysite.com.access.log;
  201. error_log /var/log/nginx/mysite.com.error.log info;
  202.  
  203. # index.php
  204. index index.php;
  205.  
  206. # index.php fallback
  207. location / {
  208. try_files $uri $uri/ /index.php?$query_string;
  209. }
  210.  
  211. # handle .php
  212. location ~ \.php$ {
  213. include nginxconfig.io/php_fastcgi.conf;
  214. }
  215.  
  216. # additional config
  217. include nginxconfig.io/general.conf;
  218. include nginxconfig.io/wordpress.conf;
  219.  
  220. include snippets/phpmyadmin.conf;
  221.  
  222. }
  223.  
  224.  
  225.  
  226. server {
  227. listen 80;
  228. listen [::]:80;
  229. server_name phpmyadmin.mysite.com;
  230. root /usr/share/phpmyadmin;
  231. }
  232.  
  233.  
  234.  
  235. # non-www, subdomains redirect
  236. server {
  237. listen 80;
  238. listen [::]:80;
  239.  
  240. server_name .mysite.com;
  241.  
  242. return 301 http://www.mysite.com$request_uri;
  243. }
  244.  
  245. # configuration file /etc/nginx/nginxconfig.io/security.conf:
  246. # security headers
  247. add_header X-Frame-Options "SAMEORIGIN" always;
  248. add_header X-XSS-Protection "1; mode=block" always;
  249. add_header X-Content-Type-Options "nosniff" always;
  250. add_header Referrer-Policy "origin" always;
  251. add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
  252.  
  253. # . files
  254. location ~ /\.(?!well-known) {
  255. deny all;
  256. }
  257.  
  258. # configuration file /etc/nginx/nginxconfig.io/php_fastcgi.conf:
  259. # 404
  260. try_files $fastcgi_script_name =404;
  261.  
  262. # default fastcgi_params
  263. include fastcgi_params;
  264.  
  265. # fastcgi settings
  266. fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
  267. fastcgi_index index.php;
  268. fastcgi_buffers 8 16k;
  269. fastcgi_buffer_size 32k;
  270.  
  271. # fastcgi params
  272. fastcgi_param DOCUMENT_ROOT $realpath_root;
  273. fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
  274. #fastcgi_param PHP_ADMIN_VALUE "open_basedir=$base/:/usr/lib/php/:/tmp/";
  275.  
  276. # configuration file /etc/nginx/fastcgi_params:
  277.  
  278. fastcgi_param QUERY_STRING $query_string;
  279. fastcgi_param REQUEST_METHOD $request_method;
  280. fastcgi_param CONTENT_TYPE $content_type;
  281. fastcgi_param CONTENT_LENGTH $content_length;
  282.  
  283. fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  284. fastcgi_param REQUEST_URI $request_uri;
  285. fastcgi_param DOCUMENT_URI $document_uri;
  286. fastcgi_param DOCUMENT_ROOT $document_root;
  287. fastcgi_param SERVER_PROTOCOL $server_protocol;
  288. fastcgi_param REQUEST_SCHEME $scheme;
  289. fastcgi_param HTTPS $https if_not_empty;
  290.  
  291. fastcgi_param GATEWAY_INTERFACE CGI/1.1;
  292. fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
  293.  
  294. fastcgi_param REMOTE_ADDR $remote_addr;
  295. fastcgi_param REMOTE_PORT $remote_port;
  296. fastcgi_param SERVER_ADDR $server_addr;
  297. fastcgi_param SERVER_PORT $server_port;
  298. fastcgi_param SERVER_NAME $server_name;
  299.  
  300. # PHP only, required if PHP was built with --enable-force-cgi-redirect
  301. fastcgi_param REDIRECT_STATUS 200;
  302.  
  303. # configuration file /etc/nginx/nginxconfig.io/general.conf:
  304. # favicon.ico
  305. location = /favicon.ico {
  306. log_not_found off;
  307. access_log off;
  308. }
  309.  
  310. # robots.txt
  311. location = /robots.txt {
  312. log_not_found off;
  313. access_log off;
  314. }
  315.  
  316. # assets, media
  317. location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
  318. expires 7d;
  319. access_log off;
  320. }
  321.  
  322. # svg, fonts
  323. location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
  324. add_header Access-Control-Allow-Origin "*";
  325. expires 7d;
  326. access_log off;
  327. }
  328.  
  329. # gzip
  330. gzip on;
  331. gzip_vary on;
  332. gzip_proxied any;
  333. gzip_comp_level 6;
  334. gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
  335.  
  336. # configuration file /etc/nginx/nginxconfig.io/wordpress.conf:
  337. # WordPress: allow TinyMCE
  338. location = /wp-includes/js/tinymce/wp-tinymce.php {
  339. include nginxconfig.io/php_fastcgi.conf;
  340. }
  341.  
  342. # WordPress: deny wp-content, wp-includes php files
  343. location ~* ^/(?:wp-content|wp-includes)/.*\.php$ {
  344. deny all;
  345. }
  346.  
  347. # WordPress: deny wp-content/uploads nasty stuff
  348. location ~* ^/wp-content/uploads/.*\.(?:s?html?|php|js|swf)$ {
  349. deny all;
  350. }
  351.  
  352. # WordPress: deny wp-content/plugins (except earlier rules)
  353. location ~ ^/wp-content/plugins {
  354. deny all;
  355. }
  356.  
  357. # WordPress: deny scripts and styles concat
  358. location ~* \/wp-admin\/load-(?:scripts|styles)\.php {
  359. deny all;
  360. }
  361.  
  362. # WordPress: deny general stuff
  363. location ~* ^/(?:xmlrpc\.php|wp-links-opml\.php|wp-config\.php|wp-config-sample\.php|wp-comments-post\.php|readme\.html|license\.txt)$ {
  364. deny all;
  365. }
  366.  
  367. # WordPress: throttle wp-login.php
  368. location = /wp-login.php {
  369. limit_req zone=login burst=2 nodelay;
  370. include nginxconfig.io/php_fastcgi.conf;
  371. }
  372.  
  373. # configuration file /etc/nginx/snippets/phpmyadmin.conf:
  374. location /phpmyadmin {
  375. root /usr/share/;
  376. index index.php index.html index.htm;
  377. location ~ ^/phpmyadmin/(.+\.php)$ {
  378. try_files $uri =404;
  379. root /usr/share/;
  380. fastcgi_pass unix:/run/php/php7.2-fpm.sock;
  381. fastcgi_index index.php;
  382. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  383. include /etc/nginx/fastcgi_params;
  384. }
  385.  
  386. location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
  387. root /usr/share/;
  388. }
  389. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement