Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBoersma committed Jun 5, 2017
1 parent f62ef6e commit 3c16a4d
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 109 deletions.
51 changes: 18 additions & 33 deletions Doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ This code example shows how to create a FastCGI application and receive requests
var app = new FCGIApplication();

// Handle requests by responding with a 'Hello World' message
app.OnRequestReceived += (sender, request) => {
request.WriteResponseASCII("HTTP/1.1 200 OK\nContent-Type:text/html\n\nHello World!");
app.OnRequestReceived += (sender, request) =>
{
var responseString =
"HTTP/1.1 200 OK\n"
+ "Content-Type:text/html\n"
+ "\n"
+ "Hello World!";

request.WriteResponseASCII(responseString);
request.Close();
};

Expand Down Expand Up @@ -62,41 +69,19 @@ If you think you found a bug, you can open an Issue on [Github](https://github.c

## Web server configuration

Refer to your web server documentation for configuration details:

* [nginx documentation](http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html)
* [Apache documentation](http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html)

For nginx, add this to pass all requests to your FastCGI application:
For nginx, use `fastcgi_pass` to pass requests to your FastCGI application:

location / {
include fastcgi_params;
fastcgi_pass 127.0.0.1:19000;
fastcgi_pass 127.0.0.1:19000; # Pass all requests to port 19000 via FastCGI.
include fastcgi_params; # (Optional): Set several FastCGI parameters like the remote IP, the URI, and other useful metadata.
}

Where fastcgi_params is a file in your nginx config folder, containing something like:
In the example above, `fastcgi_params` is a file that defines FastCGI parameters. It is included in most nginx default configurations and contains lines like these:

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REMOTE_ADDR $remote_addr;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
For more details, refer to your web server documentation for configuration details:

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

fastcgi_param HTTPS $https;
* [nginx documentation](http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html)
* [Apache documentation](http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html)
2 changes: 1 addition & 1 deletion FastCGI.Demo/FastCGI.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FastCGI\FastCGI.csproj">
<Project>{4e960156-aafa-44e7-9f0e-fb19069710a6}</Project>
<Project>{4E960156-AAFA-44E7-9F0E-FB19069710A6}</Project>
<Name>FastCGI</Name>
</ProjectReference>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion FastCGI.Tests/FastCGI.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand Down
105 changes: 71 additions & 34 deletions FastCGI.sln
Original file line number Diff line number Diff line change
@@ -1,34 +1,71 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastCGI.Demo", "FastCGI.Demo\FastCGI.Demo.csproj", "{C8332CD7-2271-4506-934B-63BFDF2C6F08}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastCGI", "FastCGI\FastCGI.csproj", "{4E960156-AAFA-44E7-9F0E-FB19069710A6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastCGI.Tests", "FastCGI.Tests\FastCGI.Tests.csproj", "{E455D80A-F5D1-442C-BC25-3BC06BC17D72}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C8332CD7-2271-4506-934B-63BFDF2C6F08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8332CD7-2271-4506-934B-63BFDF2C6F08}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8332CD7-2271-4506-934B-63BFDF2C6F08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8332CD7-2271-4506-934B-63BFDF2C6F08}.Release|Any CPU.Build.0 = Release|Any CPU
{4E960156-AAFA-44E7-9F0E-FB19069710A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E960156-AAFA-44E7-9F0E-FB19069710A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E960156-AAFA-44E7-9F0E-FB19069710A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E960156-AAFA-44E7-9F0E-FB19069710A6}.Release|Any CPU.Build.0 = Release|Any CPU
{E455D80A-F5D1-442C-BC25-3BC06BC17D72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E455D80A-F5D1-442C-BC25-3BC06BC17D72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E455D80A-F5D1-442C-BC25-3BC06BC17D72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E455D80A-F5D1-442C-BC25-3BC06BC17D72}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastCGI.Demo", "FastCGI.Demo\FastCGI.Demo.csproj", "{C8332CD7-2271-4506-934B-63BFDF2C6F08}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastCGI", "FastCGI\FastCGI.csproj", "{4E960156-AAFA-44E7-9F0E-FB19069710A6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastCGI.Tests", "FastCGI.Tests\FastCGI.Tests.csproj", "{E455D80A-F5D1-442C-BC25-3BC06BC17D72}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4E960156-AAFA-44E7-9F0E-FB19069710A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E960156-AAFA-44E7-9F0E-FB19069710A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E960156-AAFA-44E7-9F0E-FB19069710A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E960156-AAFA-44E7-9F0E-FB19069710A6}.Release|Any CPU.Build.0 = Release|Any CPU
{C8332CD7-2271-4506-934B-63BFDF2C6F08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8332CD7-2271-4506-934B-63BFDF2C6F08}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8332CD7-2271-4506-934B-63BFDF2C6F08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8332CD7-2271-4506-934B-63BFDF2C6F08}.Release|Any CPU.Build.0 = Release|Any CPU
{E455D80A-F5D1-442C-BC25-3BC06BC17D72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E455D80A-F5D1-442C-BC25-3BC06BC17D72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E455D80A-F5D1-442C-BC25-3BC06BC17D72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E455D80A-F5D1-442C-BC25-3BC06BC17D72}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
Policies = $0
$0.TextStylePolicy = $1
$1.FileWidth = 120
$1.EolMarker = Unix
$1.inheritsSet = VisualStudio
$1.inheritsScope = text/plain
$1.scope = text/x-csharp
$0.CSharpFormattingPolicy = $2
$2.IndentSwitchBody = True
$2.IndentBlocksInsideExpressions = True
$2.AnonymousMethodBraceStyle = NextLine
$2.PropertyBraceStyle = NextLine
$2.PropertyGetBraceStyle = NextLine
$2.PropertySetBraceStyle = NextLine
$2.EventBraceStyle = NextLine
$2.EventAddBraceStyle = NextLine
$2.EventRemoveBraceStyle = NextLine
$2.StatementBraceStyle = NextLine
$2.ElseNewLinePlacement = NewLine
$2.CatchNewLinePlacement = NewLine
$2.FinallyNewLinePlacement = NewLine
$2.WhileNewLinePlacement = DoNotCare
$2.ArrayInitializerWrapping = DoNotChange
$2.ArrayInitializerBraceStyle = NextLine
$2.BeforeMethodDeclarationParentheses = False
$2.BeforeMethodCallParentheses = False
$2.BeforeConstructorDeclarationParentheses = False
$2.NewLineBeforeConstructorInitializerColon = NewLine
$2.NewLineAfterConstructorInitializerColon = SameLine
$2.BeforeDelegateDeclarationParentheses = False
$2.NewParentheses = False
$2.SpacesBeforeBrackets = False
$2.inheritsSet = Mono
$2.inheritsScope = text/x-csharp
$2.scope = text/x-csharp
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
15 changes: 11 additions & 4 deletions FastCGI/FCGIApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ namespace FastCGI
/// var app = new FCGIApplication();
///
/// // Handle requests by responding with a 'Hello World' message
/// app.OnRequestReceived += (sender, request) => {
/// request.WriteResponseASCII("HTTP/1.1 200 OK\nContent-Type:text/html\n\nHello World!");
/// request.Close();
/// };
/// app.OnRequestReceived += (sender, request) =>
/// {
/// var responseString =
/// "HTTP/1.1 200 OK\n"
/// + "Content-Type:text/html\n"
/// + "\n"
/// + "Hello World!";
///
/// request.WriteResponseASCII(responseString);
/// request.Close();
/// };
/// // Start listening on port 19000
/// app.Run(19000);
///
Expand Down
52 changes: 16 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This means that you can write web applications in C# that serve dynamic content.

## License and contributing

This software is distributed under the terms of the MIT license. You can use it for your own projects for free under the conditions specified in LICENSE.txt.
This software is distributed under the terms of the MIT license. You can use it for your own projects for free under the conditions specified in LICENSE.txt.

If you have questions, feel free to contact me. Visit [lukas-boersma.com](https://lukas-boersma.com) for my contact details.

Expand Down Expand Up @@ -45,8 +45,15 @@ This code example shows how to create a FastCGI application and receive requests
var app = new FCGIApplication();

// Handle requests by responding with a 'Hello World' message
app.OnRequestReceived += (sender, request) => {
request.WriteResponseASCII("HTTP/1.1 200 OK\nContent-Type:text/html\n\nHello World!");
app.OnRequestReceived += (sender, request) =>
{
var responseString =
"HTTP/1.1 200 OK\n"
+ "Content-Type:text/html\n"
+ "\n"
+ "Hello World!";

request.WriteResponseASCII(responseString);
request.Close();
};

Expand All @@ -56,41 +63,14 @@ app.Run(19000);

## Web server configuration

Refer to your web server documentation for configuration details:

* [nginx documentation](http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html)
* [Apache documentation](http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html)

For nginx, add this to pass all requests to your FastCGI application:
For nginx, use `fastcgi_pass` to pass requests to your FastCGI application:

location / {
include fastcgi_params;
fastcgi_pass 127.0.0.1:19000;
fastcgi_pass 127.0.0.1:19000; # Pass all requests to port 19000 via FastCGI.
include fastcgi_params; # (Optional): Set several FastCGI parameters like the remote IP and other metadata.
}

Where fastcgi_params is a file in your nginx config folder, containing something like:

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
For more details, refer to your web server documentation for configuration details:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

fastcgi_param HTTPS $https;
* [nginx documentation](http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html)
* [Apache documentation](http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html)

0 comments on commit 3c16a4d

Please sign in to comment.