Include directive in Apache - similar directive in IIS7? - iis-7

Apache's Include directive includes other configuration files from within the server configuration files.
e.g.,
Include /usr/local/apache2/conf/vhosts/*.conf
Does IIS7 have a similar directive to include other configuration files?

Yes - please review any/all of the following:
Can a web.config read from an external xml file?
Moving IIS7 url rewrite section out of the web.config file
IIS7 urlrewrite module - Rules in external xml file

Related

Redirecting to other url when specific url is called from the browser through nginx

I have hosted my JavaScript application in aws ec2 server. I'm using centos 7 and placed my JavaScript static files in /usr/share/nginx/html directory. I'm using nginx as reverse proxy.I have one yaml file inside this JavaScript files that is accessible through the browser. The yaml file contains all the sensitive information but that file is necessary to load my application. Is there any way to disable direct access to that file in browser. Or is there any way to disable that information disclosure in browser through nginx.Thanks in advance for the help.
I have tried
location /properties.yaml {
rewrite ^/$ /login.html permanent;
}
But this is not working. Then i tried to read that file from other location like
location /properties.yaml{
try_files $uri /var/www/html/properties.yaml;
}
Could you please guide.

How to disable/deactivate nginx file compression/merge?

We use PLESK and pagespeed with nginx. Now all CSS-files are compressed and merged into one single file. Like test.com/A.style.css+style2.css+plugin.css+test.css etc.
How can i disable that file compression for development in PLESK with additional nginx commands or something? I want to use nginx but without merging of CSS-files.
Thanks!
Pagespeed uses gzip compression, so you can just disable it completely using directive:
gzip off;
Or specify the gzip_types values without text/css files.
Check the module description here.
In case you manage website configuration in Plesk, you can add additional nginx directives in Plesk > Subscriptions > example.com > Apache & Nginx Settings > Additional nginx directives.

Nginx how to add extra server configuration to without modifying nginx.conf

I want to add this extra config to my nginx.conf:
server {
listen 0.0.0.0:8081;
rewrite ^ https://$host$request_uri? redirect;
}
But as my app is deployed in a hosting service I don't want to modify the already present nginx.conf. It can be problematic.
Is there any way I can add this extra configuration without modifying nginx.conf?
There is no way you can add extra server configuration without modifying nginx.conf first. But good news is that you will have to modify nginx.conf only for once.
Just add this line in your nginx.conf
include /etc/nginx/config.d/*.conf;
You can name directory and path as per your choice.
create directory and save your extra configuration in that as extra.conf with .conf extension. Any files you save with .confextension in this directory /etc/nginx/config.d will be automatically added to your nginx.conf.
You can even save multiple configurations like extra1.conf and extra2.conf
for different uses and you can delete one without affecting other.
There is one way, but you need to insert some changes to nginx.conf
you can create a template file extra_config that contains
server {
listen 0.0.0.0:8081;
rewrite ^ https://$host$request_uri? redirect;
}
and in nginx.conf add this string
{% include '%path_to_template_file%/extra_config'}

Does Nginx use .htacess? If not, then how is my WordPress site using .htaccess?

I ask this question as I have a WordPress blog on an Nginx server that clearly has an .htacess file; however, I was told by a co-worker that Nginx does not use .htaccess. If Nginx doesn't use .htacess, then what does it use?
Just because there's a .htaccess file in the folder doesn't mean it's being used in any way by nginx.
You can set up nginx to work with WordPress via the nginx configuration files. http://wiki.nginx.org/WordPress

How to rewrite .aspx to .html or .php with htaccess

I'm trying to rewrite some URLs that have a .aspx extension to .html. I looked around and saw that you can put something like
RewriteEngine On
RewriteCond %{QUERY_STRING} ^file=(.+)$
RewriteRule ^(.+)\.aspx$ $1.php?f=%1
in the htaccess to rewrite any .aspx to .php. However, when I put that in the .htaccess file, it doesn't seem to work for me. mod_rewrite is enabled and the site is on a Linux server so those are not the issue. If I try to go anywhere with a .aspx extension, I get a "Server Error in '/' Application." error.
You can see this by going here http://www.netstar.co.uk.php5-20.websitetestlink.com/about-us.aspx. Any help for this would be greatly appreciated...it has been a thorn in my side for quite some time.
You say that the site is on a linux server and mod_rewrite is enabled.
However, when I navigate to the link you provided, I get the following HTTP response headers:
Cache-Control private
Content-Type text/html; charset=utf-8
Server Microsoft-IIS/7.0
X-AspNet-Version 2.0.50727
X-Powered-By ASP.NET
Date Thu, 31 Mar 2011 15:24:33 GMT
Content-Length 1508
Which tells me that no, it's not a Linux server, no it isn't running Apache, and no it doesn't have mod_rewrite enabled.
But I'm not surprised by any of this, because you're writing aspx code, which would normally not be run on a linux/apache server anyway.
I suggest you investigate the IIS equivalent of mod_rewrite. Try starting at this question here on SO: mod_rewrite equivalent for IIS 7.0
My usual mistake: you need to enable .htaccess files in httpd.conf (or, on e.g. Ubuntu, in your site configuration file). In the main <Directory> block (or is it <Location>?) there's probably a directive that ignores .htaccess files in the root directory, or in all directories.
It's probably easiest to just add your rewrite rules to the root <Directory> instead. Remember to restart apache after changing these files.

Resources