diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index b60300e2b15a429081d69f181b29b4a5824a62ef..c7f955d9454f778f20d4d17642307307d23d6330 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -2226,7 +2226,10 @@ class installer_base {
 				$tpl->setVar('logging','yes');
 			}
 
-
+			if($conf['rspamd']['installed'] == true) {
+				$tpl->setVar('use_rspamd', 'yes');
+			}
+			
 			// comment out the listen directive if port is 80 or 443
 			if($conf['web']['apps_vhost_ip'] == 80 or $conf['web']['apps_vhost_ip'] == 443) {
 				$tpl->setVar('vhost_port_listen','#');
@@ -2294,6 +2297,12 @@ class installer_base {
 				$apps_vhost_ip = $conf['web']['apps_vhost_ip'].':';
 			}
 
+			if($conf['rspamd']['installed'] == true) {
+				$content = str_replace('{use_rspamd}', '', $content);
+			} else {
+				$content = str_replace('{use_rspamd}', '# ', $content);
+			}
+			
 			$socket_dir = escapeshellcmd($conf['nginx']['php_fpm_socket_dir']);
 			if(substr($socket_dir, -1) != '/') $socket_dir .= '/';
 			if(!is_dir($socket_dir)) exec('mkdir -p '.$socket_dir);
diff --git a/install/tpl/apache_apps.vhost.master b/install/tpl/apache_apps.vhost.master
index ee1b693097a200505f42c7a7da3313b134d016b9..9cccf8d38ed0e3f6adf7466396803a2856c886cb 100644
--- a/install/tpl/apache_apps.vhost.master
+++ b/install/tpl/apache_apps.vhost.master
@@ -19,6 +19,12 @@
 	RequestHeader unset Proxy early
   </IfModule>
   
+  {tmpl_if name="enable_spdy" op="==" value="y"}
+  <IfModule spdy_module>
+	SpdyEnabled on
+  </IfModule>
+  {/tmpl_if}
+
   <IfModule mod_php5.c>
     DocumentRoot {tmpl_var name='apps_vhost_dir'}
     AddType application/x-httpd-php .php
@@ -68,6 +74,18 @@
     </Directory>
   </IfModule>
 
+{tmpl_if name="use_rspamd"}
+  <Location /rspamd>
+        Order allow,deny
+        Allow from all
+  </Location>
+  RewriteEngine On
+  RewriteRule ^/rspamd$ /rspamd/ [R,L]
+  RewriteRule ^/rspamd/(.*) http://127.0.0.1:11334/$1 [P]
+{/tmpl_if}
+
+
+
 </VirtualHost>
 
 
diff --git a/install/tpl/nginx_apps.vhost.master b/install/tpl/nginx_apps.vhost.master
index 3d00d11106d48a3e8289d6fbc7ca057bdb34620a..871dff8c57dddff8f6a45193345928e90c1dcb4a 100644
--- a/install/tpl/nginx_apps.vhost.master
+++ b/install/tpl/nginx_apps.vhost.master
@@ -208,4 +208,28 @@ server {
                alias /var/lib/mailman/archives/public;
                autoindex on;
         }
+
+        {use_rspamd}location /rspamd/ {
+                {use_rspamd}proxy_pass http://127.0.0.1:11334/;
+                {use_rspamd}rewrite ^//(.*) /$1;
+                {use_rspamd}proxy_set_header X-Forwarded-Proto $scheme;
+                {use_rspamd}proxy_set_header Host $host;
+                {use_rspamd}proxy_set_header X-Real-IP $remote_addr;
+                {use_rspamd}proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+                {use_rspamd}proxy_pass_header Authorization;
+                {use_rspamd}client_max_body_size 0;
+                {use_rspamd}client_body_buffer_size 1m;
+                {use_rspamd}proxy_intercept_errors on;
+                {use_rspamd}proxy_buffering on;
+                {use_rspamd}proxy_buffer_size 128k;
+                {use_rspamd}proxy_buffers 256 16k;
+                {use_rspamd}proxy_busy_buffers_size 256k;
+                {use_rspamd}proxy_temp_file_write_size 256k;
+                {use_rspamd}proxy_max_temp_file_size 0;
+                {use_rspamd}proxy_read_timeout 300;
+                {use_rspamd}
+                {use_rspamd}location ~* ^/rspamd/(.+\.(jpg|jpeg|gif|css|png|js|ico|html?|xml|txt))$ {
+                       {use_rspamd}alias /usr/share/rspamd/www/$1;
+                {use_rspamd}}
+        {use_rspamd}}
 }