<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="lt">
	<id>https://wiki.eofnet.lt/w//index.php?action=history&amp;feed=atom&amp;title=Nginx_saugumo_taisykl%C4%97s</id>
	<title>Nginx saugumo taisyklės - Versijų istorija</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.eofnet.lt/w//index.php?action=history&amp;feed=atom&amp;title=Nginx_saugumo_taisykl%C4%97s"/>
	<link rel="alternate" type="text/html" href="https://wiki.eofnet.lt/w//index.php?title=Nginx_saugumo_taisykl%C4%97s&amp;action=history"/>
	<updated>2026-04-23T21:24:28Z</updated>
	<subtitle>Šio puslapio versijų istorija projekte</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.eofnet.lt/w//index.php?title=Nginx_saugumo_taisykl%C4%97s&amp;diff=8405&amp;oldid=prev</id>
		<title>\dev\null 13:02, 26 rugpjūčio 2017</title>
		<link rel="alternate" type="text/html" href="https://wiki.eofnet.lt/w//index.php?title=Nginx_saugumo_taisykl%C4%97s&amp;diff=8405&amp;oldid=prev"/>
		<updated>2017-08-26T13:02:36Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Naujas puslapis&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Keletas taisyklių saugumui bei spartai pakelti. Taisyklės naudojamos nginx.conf.&lt;br /&gt;
&lt;br /&gt;
 # don't send the nginx version number in error pages and Server header&lt;br /&gt;
 server_tokens off;&lt;br /&gt;
 # config to don't allow the browser to render the page inside an frame or iframe&lt;br /&gt;
 # and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking&lt;br /&gt;
 # if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri&lt;br /&gt;
 # https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options&lt;br /&gt;
 add_header X-Frame-Options SAMEORIGIN;&lt;br /&gt;
 # when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header, &lt;br /&gt;
 # to disable content-type sniffing on some browsers.&lt;br /&gt;
 # https://www.owasp.org/index.php/List_of_useful_HTTP_headers&lt;br /&gt;
 # currently suppoorted in IE &amp;gt; 8 http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx&lt;br /&gt;
 # http://msdn.microsoft.com/en-us/library/ie/gg622941(v=vs.85).aspx &lt;br /&gt;
 # 'soon' on Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=471020&lt;br /&gt;
 add_header X-Content-Type-Options nosniff;&lt;br /&gt;
 # This header enables the Cross-site scripting (XSS) filter built into most recent web browsers.&lt;br /&gt;
 # It's usually enabled by default anyway, so the role of this header is to re-enable the filter for &lt;br /&gt;
 # this particular website if it was disabled by the user.&lt;br /&gt;
 # https://www.owasp.org/index.php/List_of_useful_HTTP_headers&lt;br /&gt;
 add_header X-XSS-Protection &amp;quot;1; mode=block&amp;quot;;&lt;br /&gt;
 # with Content Security Policy (CSP) enabled(and a browser that supports it(http://caniuse.com/#feat=contentsecuritypolicy),&lt;br /&gt;
 # you can tell the browser that it can only download content from the domains you explicitly allow&lt;br /&gt;
 # http://www.html5rocks.com/en/tutorials/security/content-security-policy/&lt;br /&gt;
 # https://www.owasp.org/index.php/Content_Security_Policy&lt;br /&gt;
 # I need to change our application code so we can increase security by disabling 'unsafe-inline' 'unsafe-eval'&lt;br /&gt;
 # directives for css and js(if you have inline css or js, you will need to keep it too).&lt;br /&gt;
 # more: http://www.html5rocks.com/en/tutorials/security/content-security-policy/#inline-code-considered-harmful&lt;br /&gt;
 add_header &amp;lt;nowiki&amp;gt;Content-Security-Policy &amp;quot;default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://ssl.google-analytics.com https://assets.zendesk.com https://connect.facebook.net; img-src  'self' https://ssl.google-analytics.com https://s-static.ak.facebook.com https://assets.zendesk.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://assets.zendesk.com; font-src  'self' https://themes.googleusercontent.com; frame-src https://assets.zendesk.com https://www.facebook.com https://s-static.ak.facebook.com https://tautt.zendesk.com; object-src 'none'&amp;quot;;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 # Common bandwidth hoggers and hacking tools.&lt;br /&gt;
 map $http_user_agent $limit_bots {&lt;br /&gt;
    default 0;&lt;br /&gt;
    ~*(AltaVista|Slurp|BlackWidow|Bot|ChinaClaw|Custo|DISCo|Download|Demon|eCatch|EirGrabber|EmailSiphon|EmailWolf|SuperHTTP|Surfbot|WebWhacker) 1;&lt;br /&gt;
    ~*(Express|WebPictures|ExtractorPro|EyeNetIE|FlashGet|GetRight|GetWeb!|Go!Zilla|Go-Ahead-Got-It|GrabNet|Grafula|HMView|Go!Zilla|Go-Ahead-Got-It) 1;&lt;br /&gt;
     ~*(rafula|HMView|HTTrack|Stripper|Sucker|Indy|InterGET|Ninja|JetCar|Spider|larbin|LeechFTP|Downloader|tool|Navroad|NearSite|NetAnts|tAkeOut|WWWOFFLE) 1;&lt;br /&gt;
    ~*(GrabNet|NetSpider|Vampire|NetZIP|Octopus|Offline|PageGrabber|Foto|pavuk|pcBrowser|RealDownload|ReGet|SiteSnagger|SmartDownload|SuperBot|WebSpider) 1;&lt;br /&gt;
    ~*(Teleport|VoidEYE|Collector|WebAuto|WebCopier|WebFetch|WebGo|WebLeacher|WebReaper|WebSauger|eXtractor|Quester|WebStripper|WebZIP|Wget|Widow|Zeus) 1;&lt;br /&gt;
    ~*(Twengabot|htmlparser|libwww|Python|perl|urllib|scan|Curl|email|PycURL|Pyth|PyQ|WebCollector|WebCopy|webcraw) 1;&lt;br /&gt;
 }&lt;br /&gt;
 # Expires map&lt;br /&gt;
 map $sent_http_content_type $expires {&lt;br /&gt;
    default                    off;&lt;br /&gt;
    text/html                  epoch;&lt;br /&gt;
    text/css                   max;&lt;br /&gt;
    application/javascript     max;&lt;br /&gt;
    ~image/                    max;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==  Taisyklės naudojamos server {} bloke. ==&lt;br /&gt;
&lt;br /&gt;
=== SSL ===&lt;br /&gt;
 ssl_session_cache shared:SSL:50m;&lt;br /&gt;
 ssl_session_timeout 5m;&lt;br /&gt;
  # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits&lt;br /&gt;
  ssl_dhparam /etc/nginx/ssl/dhparam.pem;&lt;br /&gt;
  # enables server-side protection from BEAST attacks&lt;br /&gt;
  # http://blog.ivanristic.com/2013/09/is-beast-still-a-threat.html&lt;br /&gt;
  ssl_prefer_server_ciphers on;&lt;br /&gt;
  # disable SSLv3(enabled by default since nginx 0.8.19) since it's less secure then TLS http://en.wikipedia.org/wiki/Secure_Sockets_Layer#SSL_3.0&lt;br /&gt;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;&lt;br /&gt;
  # ciphers chosen for forward secrecy and compatibility&lt;br /&gt;
  # http://blog.ivanristic.com/2013/08/configuring-apache-nginx-and-openssl-for-forward-secrecy.html&lt;br /&gt;
  ssl_ciphers &amp;quot;ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4&amp;quot;;&lt;br /&gt;
  # enable ocsp stapling (mechanism by which a site can convey certificate revocation information to visitors in a privacy-preserving, scalable manner)&lt;br /&gt;
  # http://blog.mozilla.org/security/2013/07/29/ocsp-stapling-in-firefox/&lt;br /&gt;
  resolver 8.8.8.8;&lt;br /&gt;
  ssl_stapling on;&lt;br /&gt;
  ssl_trusted_certificate /etc/nginx/ssl/star_forgott_com.crt;&lt;br /&gt;
  # config to enable HSTS(HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security&lt;br /&gt;
  # to avoid ssl stripping https://en.wikipedia.org/wiki/SSL_stripping#SSL_stripping&lt;br /&gt;
  add_header Strict-Transport-Security &amp;quot;max-age=31536000; includeSubdomains;&amp;quot;;&lt;br /&gt;
=== Performance ===&lt;br /&gt;
 expires $expires;&lt;br /&gt;
         # This block will catch static file requests, such as images, css, js&lt;br /&gt;
        # The ?: prefix is a 'non-capturing' mark, meaning we do not require&lt;br /&gt;
        # the pattern to be captured into $1 which should help improve performance&lt;br /&gt;
        location  ~ ^/pictures/product/(?:ico|css|js|gif|jpg|jpeg|png|woff|ttf|otf|svg|woff2|eot)$ {&lt;br /&gt;
            add_header Cache-Control &amp;quot;public, no-transform&amp;quot;;&lt;br /&gt;
            etag on;&lt;br /&gt;
        }&lt;br /&gt;
        # CSS and Javascript&lt;br /&gt;
        location ~* \.(?:css|js)$ {&lt;br /&gt;
          expires 1y;&lt;br /&gt;
          access_log off;&lt;br /&gt;
          add_header Cache-Control &amp;quot;public&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
=== Security ===&lt;br /&gt;
&lt;br /&gt;
             #BLOCK FROM MAP&lt;br /&gt;
            if ($limit_bots = 1) {&lt;br /&gt;
              return 403;&lt;br /&gt;
            }&lt;br /&gt;
            ##&lt;br /&gt;
            ## Deny certain Referers ###&lt;br /&gt;
            if ( $http_referer ~* (babes|forsale|girl|jewelry|love|nudit|organic|poker|porn|sex|teen) )&lt;br /&gt;
            {&lt;br /&gt;
                 return 403;&lt;br /&gt;
            }&lt;br /&gt;
            ##&lt;br /&gt;
            ## Block SQL injections &lt;br /&gt;
            set $block_sql_injections 0;&lt;br /&gt;
            if ($query_string ~ &amp;quot;union.*select.*\(&amp;quot;) {&lt;br /&gt;
                set $block_sql_injections 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($query_string ~ &amp;quot;union.*all.*select.*&amp;quot;) {&lt;br /&gt;
                set $block_sql_injections 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($query_string ~ &amp;quot;concat.*\(&amp;quot;) {&lt;br /&gt;
                set $block_sql_injections 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($block_sql_injections = 1) {&lt;br /&gt;
                return 403;&lt;br /&gt;
            }&lt;br /&gt;
            ## Block file injections&lt;br /&gt;
            set $block_file_injections 0;&lt;br /&gt;
            if ($query_string ~ &amp;quot;[a-zA-Z0-9_]=http://&amp;quot;) {&lt;br /&gt;
                set $block_file_injections 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($query_string ~ &amp;quot;[a-zA-Z0-9_]=(\.\.//?)+&amp;quot;) {&lt;br /&gt;
                set $block_file_injections 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($query_string ~ &amp;quot;[a-zA-Z0-9_]=/([a-z0-9_.]//?)+&amp;quot;) {&lt;br /&gt;
                set $block_file_injections 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($block_file_injections = 1) {&lt;br /&gt;
                return 403;&lt;br /&gt;
            }&lt;br /&gt;
            ## Block common exploits&lt;br /&gt;
            set $block_common_exploits 0;&lt;br /&gt;
            if ($query_string ~ &amp;quot;(&amp;lt;|%3C).*script.*(&amp;gt;|%3E)&amp;quot;) {&lt;br /&gt;
                set $block_common_exploits 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($query_string ~ &amp;quot;GLOBALS(=|\[|\%[0-9A-Z]{0,2})&amp;quot;) {&lt;br /&gt;
                set $block_common_exploits 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($query_string ~ &amp;quot;_REQUEST(=|\[|\%[0-9A-Z]{0,2})&amp;quot;) {&lt;br /&gt;
                set $block_common_exploits 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($query_string ~ &amp;quot;proc/self/environ&amp;quot;) {&lt;br /&gt;
                set $block_common_exploits 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($query_string ~ &amp;quot;mosConfig_[a-zA-Z_]{1,21}(=|\%3D)&amp;quot;) {&lt;br /&gt;
                set $block_common_exploits 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($query_string ~ &amp;quot;base64_(en|de)code\(.*\)&amp;quot;) {&lt;br /&gt;
                set $block_common_exploits 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($block_common_exploits = 1) {&lt;br /&gt;
                return 403;&lt;br /&gt;
            }&lt;br /&gt;
            ## Block spam&lt;br /&gt;
            set $block_spam 0;&lt;br /&gt;
            if ($query_string ~ &amp;quot;\b(ultram|unicauca|valium|viagra|vicodin|xanax|ypxaieo)\b&amp;quot;) {&lt;br /&gt;
                set $block_spam 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($query_string ~ &amp;quot;\b(erections|hoodia|huronriveracres|impotence|levitra|libido)\b&amp;quot;) {&lt;br /&gt;
                set $block_spam 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($query_string ~ &amp;quot;\b(ambien|blue\spill|cialis|cocaine|ejaculation|erectile)\b&amp;quot;) {&lt;br /&gt;
                set $block_spam 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($query_string ~ &amp;quot;\b(lipitor|phentermin|pro[sz]ac|sandyauer|tramadol|troyhamby)\b&amp;quot;) {&lt;br /&gt;
                set $block_spam 1;&lt;br /&gt;
            }&lt;br /&gt;
            if ($block_spam = 1) {&lt;br /&gt;
                return 403;&lt;br /&gt;
            }&lt;br /&gt;
            # Protect specific TXT and config files&lt;br /&gt;
            location ~ /(\.|wp-config.php|readme.html|license.txt|schema.txt|password.txt|passwords.txt) &lt;br /&gt;
            { &lt;br /&gt;
                    deny all; &lt;br /&gt;
            }&lt;br /&gt;
            # Protect ~ files&lt;br /&gt;
            location ~ ~$ &lt;br /&gt;
            { &lt;br /&gt;
                    access_log off; &lt;br /&gt;
                    log_not_found off; &lt;br /&gt;
                    deny all; &lt;br /&gt;
            }&lt;br /&gt;
            # Protect .git files&lt;br /&gt;
            location ~ /\.git &lt;br /&gt;
            { &lt;br /&gt;
                    access_log off; &lt;br /&gt;
                    log_not_found off; &lt;br /&gt;
                    deny all; &lt;br /&gt;
            }&lt;br /&gt;
            # Protect Perl/CGI/etc files&lt;br /&gt;
            location ~* \.(pl|cgi|py|sh|lua)\$ &lt;br /&gt;
            {&lt;br /&gt;
                    return 444;&lt;br /&gt;
            }&lt;br /&gt;
            # Block web attacks&lt;br /&gt;
            location ~* (roundcube|webdav|smtp|http\:|soap|w00tw00t) &lt;br /&gt;
            {&lt;br /&gt;
                    return 444;&lt;br /&gt;
            }&lt;br /&gt;
            # Protect other sensitive files&lt;br /&gt;
            location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_&lt;br /&gt;
            {&lt;br /&gt;
                    return 444;&lt;br /&gt;
            }&lt;br /&gt;
            # Block execution of PHP files in uploads folders&lt;br /&gt;
            location ~* /(?:uploads|files)/.*\.php$ &lt;br /&gt;
            {&lt;br /&gt;
                    deny all;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== http į https redirectas ==&lt;br /&gt;
&lt;br /&gt;
 server {&lt;br /&gt;
  listen 80;&lt;br /&gt;
  server_name .forgott.com;&lt;br /&gt;
  return 301 &amp;lt;nowiki&amp;gt;https://$host$request_uri;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Linux]]&lt;br /&gt;
[[Category:Httpd]]&lt;br /&gt;
[[Category:Nginx]]&lt;br /&gt;
[[Category:Ubuntu]]&lt;br /&gt;
[[Category:Debian]]&lt;br /&gt;
[[Category:Fedora]]&lt;br /&gt;
[[Category:Redhat]]&lt;br /&gt;
[[Category:Gentoo]]&lt;br /&gt;
[[Category:CentOS]]&lt;/div&gt;</summary>
		<author><name>\dev\null</name></author>
	</entry>
</feed>