Nginx name consistency (#5214)

pull/5219/head
Luke Latham 2018-01-19 14:06:42 -06:00 committed by Scott Addie
parent d1c84324e5
commit bdd7274686
4 changed files with 28 additions and 28 deletions

View File

@ -159,7 +159,7 @@ For more information, see [Session and application state](xref:fundamentals/app-
## Servers
The ASP.NET Core hosting model doesn't directly listen for requests. The hosting model relies on an HTTP server implementation to forward the request to the app. The forwarded request is wrapped as a set of feature objects that can be accessed through interfaces. ASP.NET Core includes a managed, cross-platform web server, called [Kestrel](xref:fundamentals/servers/kestrel). Kestrel is often run behind a production web server, such as [IIS](https://www.iis.net/) or [nginx](http://nginx.org). Kestrel can be run as an edge server.
The ASP.NET Core hosting model doesn't directly listen for requests. The hosting model relies on an HTTP server implementation to forward the request to the app. The forwarded request is wrapped as a set of feature objects that can be accessed through interfaces. ASP.NET Core includes a managed, cross-platform web server, called [Kestrel](xref:fundamentals/servers/kestrel). Kestrel is often run behind a production web server, such as [IIS](https://www.iis.net/) or [Nginx](http://nginx.org). Kestrel can be run as an edge server.
For more information, see [Servers](xref:fundamentals/servers/index) and the following topics:

View File

@ -36,7 +36,7 @@ In addition to *.exe* and *.dll* files, the *publish* folder for an ASP.NET Core
An ASP.NET Core app is a console app that must be started when a server boots and restarted if it crashes. To automate starts and restarts, a process manager is required. The most common process managers for ASP.NET Core are:
* Linux
* [nginx](xref:host-and-deploy/linux-nginx)
* [Nginx](xref:host-and-deploy/linux-nginx)
* [Apache](xref:host-and-deploy/linux-apache)
* Windows
* [IIS](xref:host-and-deploy/iis/index)
@ -46,11 +46,11 @@ An ASP.NET Core app is a console app that must be started when a server boots an
# [ASP.NET Core 2.x](#tab/aspnetcore2x)
If the app uses the [Kestrel](xref:fundamentals/servers/kestrel) web server, [nginx](xref:host-and-deploy/linux-nginx), [Apache](xref:host-and-deploy/linux-apache), or [IIS](xref:host-and-deploy/iis/index) can be used as a reverse proxy server. A reverse proxy server receives HTTP requests from the Internet and forwards them to Kestrel after some preliminary handling. For more information, see [When to use Kestrel with a reverse proxy](xref:fundamentals/servers/kestrel?tabs=aspnetcore2x#when-to-use-kestrel-with-a-reverse-proxy).
If the app uses the [Kestrel](xref:fundamentals/servers/kestrel) web server, [Nginx](xref:host-and-deploy/linux-nginx), [Apache](xref:host-and-deploy/linux-apache), or [IIS](xref:host-and-deploy/iis/index) can be used as a reverse proxy server. A reverse proxy server receives HTTP requests from the Internet and forwards them to Kestrel after some preliminary handling. For more information, see [When to use Kestrel with a reverse proxy](xref:fundamentals/servers/kestrel?tabs=aspnetcore2x#when-to-use-kestrel-with-a-reverse-proxy).
# [ASP.NET Core 1.x](#tab/aspnetcore1x)
If the app uses the [Kestrel](xref:fundamentals/servers/kestrel) web server and will be exposed to the Internet, use [nginx](xref:host-and-deploy/linux-nginx), [Apache](xref:host-and-deploy/linux-apache), or [IIS](xref:host-and-deploy/iis/index) as a reverse proxy server. A reverse proxy server receives HTTP requests from the Internet and forwards them to Kestrel after some preliminary handling. The main reason for using a reverse proxy is security. For more information, see [When to use Kestrel with a reverse proxy](xref:fundamentals/servers/kestrel?tabs=aspnetcore1x#when-to-use-kestrel-with-a-reverse-proxy).
If the app uses the [Kestrel](xref:fundamentals/servers/kestrel) web server and will be exposed to the Internet, use [Nginx](xref:host-and-deploy/linux-nginx), [Apache](xref:host-and-deploy/linux-apache), or [IIS](xref:host-and-deploy/iis/index) as a reverse proxy server. A reverse proxy server receives HTTP requests from the Internet and forwards them to Kestrel after some preliminary handling. The main reason for using a reverse proxy is security. For more information, see [When to use Kestrel with a reverse proxy](xref:fundamentals/servers/kestrel?tabs=aspnetcore1x#when-to-use-kestrel-with-a-reverse-proxy).
---

View File

@ -1,6 +1,6 @@
---
title: Host ASP.NET Core on Linux with nginx
description: Describes how to setup nginx as a reverse proxy on Ubuntu 16.04 to forward HTTP traffic to an ASP.NET Core web app running on Kestrel.
title: Host ASP.NET Core on Linux with Nginx
description: Describes how to setup Nginx as a reverse proxy on Ubuntu 16.04 to forward HTTP traffic to an ASP.NET Core web app running on Kestrel.
author: rick-anderson
ms.author: riande
manager: wpickett
@ -11,7 +11,7 @@ ms.technology: aspnet
ms.prod: asp.net-core
uid: host-and-deploy/linux-nginx
---
# Host ASP.NET Core on Linux with nginx
# Host ASP.NET Core on Linux with Nginx
By [Sourabh Shirhatti](https://twitter.com/sshirhatti)
@ -46,9 +46,9 @@ A reverse proxy is a common setup for serving dynamic web apps. A reverse proxy
### Why use a reverse proxy server?
Kestrel is great for serving dynamic content from ASP.NET Core; however, the web serving parts arent as feature rich as servers like IIS, Apache, or nginx. A reverse proxy server can offload work like serving static content, caching requests, compressing requests, and SSL termination from the HTTP server. A reverse proxy server may reside on a dedicated machine or may be deployed alongside an HTTP server.
Kestrel is great for serving dynamic content from ASP.NET Core; however, the web serving parts arent as feature rich as servers like IIS, Apache, or Nginx. A reverse proxy server can offload work like serving static content, caching requests, compressing requests, and SSL termination from the HTTP server. A reverse proxy server may reside on a dedicated machine or may be deployed alongside an HTTP server.
For the purposes of this guide, a single instance of nginx is used. It runs on the same server, alongside the HTTP server. Based on requirements, a different setup may be choosen.
For the purposes of this guide, a single instance of Nginx is used. It runs on the same server, alongside the HTTP server. Based on requirements, a different setup may be choosen.
Because requests are forwarded by reverse proxy, use the `ForwardedHeaders` middleware from the `Microsoft.AspNetCore.HttpOverrides` package. This middleware updates `Request.Scheme`, using the `X-Forwarded-Proto` header, so that redirect URIs and other security policies work correctly.
@ -87,28 +87,28 @@ app.UseFacebookAuthentication(new FacebookOptions()
---
### Install nginx
### Install Nginx
```bash
sudo apt-get install nginx
```
> [!NOTE]
> If optional nginx modules will be installed, building nginx from source might be required.
> If optional Nginx modules will be installed, building Nginx from source might be required.
Use `apt-get` to install nginx. The installer creates a System V init script that runs nginx as daemon on system startup. Since nginx was installed for the first time, explicitly start it by running:
Use `apt-get` to install Nginx. The installer creates a System V init script that runs Nginx as daemon on system startup. Since Nginx was installed for the first time, explicitly start it by running:
```bash
sudo service nginx start
```
Verify a browser displays the default landing page for nginx.
Verify a browser displays the default landing page for Nginx.
### Configure nginx
### Configure Nginx
To configure nginx as a reverse proxy to forward requests to our ASP.NET Core app, modify `/etc/nginx/sites-available/default`. Open it in a text editor, and replace the contents with the following:
To configure Nginx as a reverse proxy to forward requests to our ASP.NET Core app, modify `/etc/nginx/sites-available/default`. Open it in a text editor, and replace the contents with the following:
```nginx
```
server {
listen 80;
location / {
@ -122,13 +122,13 @@ server {
}
```
This nginx configuration file forwards incoming public traffic from port `80` to port `5000`.
This Nginx configuration file forwards incoming public traffic from port `80` to port `5000`.
Once the nginx configuration is established, run `sudo nginx -t` to verify the syntax of the configuration files. If the configuration file test is successful, force nginx to pick up the changes by running `sudo nginx -s reload`.
Once the Nginx configuration is established, run `sudo nginx -t` to verify the syntax of the configuration files. If the configuration file test is successful, force Nginx to pick up the changes by running `sudo nginx -s reload`.
## Monitoring the app
The server is setup to forward requests made to `http://<serveraddress>:80` on to the ASP.NET Core app running on Kestrel at `http://127.0.0.1:5000`. However, nginx is not set up to manage the Kestrel process. *systemd* can be used to create a service file to start and monitor the underlying web app. *systemd* is an init system that provides many powerful features for starting, stopping, and managing processes.
The server is setup to forward requests made to `http://<serveraddress>:80` on to the ASP.NET Core app running on Kestrel at `http://127.0.0.1:5000`. However, Nginx is not set up to manage the Kestrel process. *systemd* can be used to create a service file to start and monitor the underlying web app. *systemd* is an init system that provides many powerful features for starting, stopping, and managing processes.
### Create the service file
@ -224,9 +224,9 @@ sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
```
### Securing nginx
### Securing Nginx
The default distribution of nginx doesn't enable SSL. To enable additional security features, build from source.
The default distribution of Nginx doesn't enable SSL. To enable additional security features, build from source.
#### Download the source and install the build dependencies
@ -235,12 +235,12 @@ The default distribution of nginx doesn't enable SSL. To enable additional secur
sudo apt-get update
sudo apt-get install build-essential zlib1g-dev libpcre3-dev libssl-dev libxslt1-dev libxml2-dev libgd2-xpm-dev libgeoip-dev libgoogle-perftools-dev libperl-dev
# Download nginx 1.10.0 or latest
# Download Nginx 1.10.0 or latest
wget http://www.nginx.org/download/nginx-1.10.0.tar.gz
tar zxf nginx-1.10.0.tar.gz
```
#### Change the nginx response name
#### Change the Nginx response name
Edit *src/http/ngx_http_header_filter_module.c*:
@ -282,7 +282,7 @@ Edit the */etc/nginx/nginx.conf* configuration file. The example contains both `
[!code-nginx[Main](linux-nginx/nginx.conf?highlight=2)]
#### Secure nginx from clickjacking
#### Secure Nginx from clickjacking
Clickjacking is a malicious technique to collect an infected user's clicks. Clickjacking tricks the victim (visitor) into clicking on an infected site. Use X-FRAME-OPTIONS to secure the site.
Edit the *nginx.conf* file:
@ -291,7 +291,7 @@ Edit the *nginx.conf* file:
sudo nano /etc/nginx/nginx.conf
```
Add the line `add_header X-Frame-Options "SAMEORIGIN";` and save the file, then restart nginx.
Add the line `add_header X-Frame-Options "SAMEORIGIN";` and save the file, then restart Nginx.
#### MIME-type sniffing
@ -303,4 +303,4 @@ Edit the *nginx.conf* file:
sudo nano /etc/nginx/nginx.conf
```
Add the line `add_header X-Content-Type-Options "nosniff";` and save the file, then restart nginx.
Add the line `add_header X-Content-Type-Options "nosniff";` and save the file, then restart Nginx.

View File

@ -28,7 +28,7 @@ Use Response Compression Middleware when you're:
* Unable to use the following server-based compression technologies:
* [IIS Dynamic Compression module](https://www.iis.net/overview/reliability/dynamiccachingandcompression)
* [Apache mod_deflate module](http://httpd.apache.org/docs/current/mod/mod_deflate.html)
* [NGINX Compression and Decompression](https://www.nginx.com/resources/admin-guide/compression-and-decompression/)
* [Nginx Compression and Decompression](https://www.nginx.com/resources/admin-guide/compression-and-decompression/)
* Hosting directly on:
* [HTTP.sys server](xref:fundamentals/servers/httpsys) (formerly called [WebListener](xref:fundamentals/servers/weblistener))
* [Kestrel](xref:fundamentals/servers/kestrel)
@ -179,7 +179,7 @@ When compressing responses based on the `Accept-Encoding` header, there are pote
[!code-csharp[Main](response-compression/samples/1.x/Startup.cs?name=snippet1)]
## Middleware issue when behind an Nginx reverse proxy
When a request is proxied by Nginx, the `Accept-Encoding` header is removed. This prevents the middleware from compressing the response. For more information, see [NGINX: Compression and Decompression](https://www.nginx.com/resources/admin-guide/compression-and-decompression/). This issue is tracked by [Figure out pass-through compression for nginx (BasicMiddleware #123)](https://github.com/aspnet/BasicMiddleware/issues/123).
When a request is proxied by Nginx, the `Accept-Encoding` header is removed. This prevents the middleware from compressing the response. For more information, see [NGINX: Compression and Decompression](https://www.nginx.com/resources/admin-guide/compression-and-decompression/). This issue is tracked by [Figure out pass-through compression for Nginx (BasicMiddleware #123)](https://github.com/aspnet/BasicMiddleware/issues/123).
## Working with IIS dynamic compression
If you have an active IIS Dynamic Compression Module configured at the server level that you would like to disable for an app, you can do so with an addition to your *web.config* file. For more information, see [Disabling IIS modules](xref:host-and-deploy/iis/modules#disabling-iis-modules).