 In this article I will show how to configure a simple bunch of nginx + Asp.Net. By idle time, it should be understood that some specific features of projects, the delineation of user rights, high loads, etc. need to be configured separately (especially Asp.Net). Article is written at the request of habrauzera mace .
 In this article I will show how to configure a simple bunch of nginx + Asp.Net. By idle time, it should be understood that some specific features of projects, the delineation of user rights, high loads, etc. need to be configured separately (especially Asp.Net). Article is written at the request of habrauzera mace .You need to be able to support it.
nginx is to install from the dotdeb.org repositories. By the way, a very good repository: in addition to nginx , there are always the latest versions of php , mysql (percona) and redis . Slightly more difficult to install from source - about it just below.sources.list , prescribe the GnuPG key and update the sources: root@falco:~# echo "deb http://packages.dotdeb.org stable all" >> /etc/apt/sources.list root@falco:~# wget -q http://www.dotdeb.org/dotdeb.gpg -O- | apt-key add - root@falco:~# apt-get update apt-cache policy nginx command we will see the following: root@falco:~# apt-cache policy nginx nginx: : () : 1.0.2-1~dotdeb.1  : 1.0.2-1~dotdeb.1 0 500 http://packages.dotdeb.org/ stable/all amd64 Packages 0.7.67-3 0 500 http://mirror.yandex.ru/debian/ squeeze/main amd64 Packages  root@falco:~# apt-get install nginx nginx from source, then ./configure must be run with the following parameters: ./configure --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module nginx-full package, except for the absence of third-party modules Upstream Fair Queue and Echo.mono and xsp from there through pining . root@falco:~# wget "http://ftp.novell.com/pub/mono/sources/mono/mono-2.10.2.tar.bz2" root@falco:~# wget "http://ftp.novell.com/pub/mono/sources/xsp/xsp-2.10.2.tar.bz2"  root@falco:~# tar -xvf mono-2.10.2.tar.bz2 root@falco:~# tar -xvf xsp-2.10.2.tar.bz2 tar scolds for the absence of bzip2 (in minimal exactly scolds), you need to put it: root@falco:~# apt-get install bzip2 mono and xsp we need the following: root@falco:~# apt-get install build-essential gawk bison gettext libgdiplus pkg-config libglib2.0-0 libglib2.0-dev  root@falco:~/mono-2.10.2# ./configure --prefix=/usr --sysconfdir=/etc/mono root@falco:~/mono-2.10.2# make && make install mono --version command will show us the long-awaited and cherished: root@falco:~/mono-2.10.2# mono --version Mono JIT compiler version 2.10.2 (tarball   11 15:54:39 MSD 2011) Copyright (C) 2002-2011 Novell, Inc and Contributors. www.mono-project.com TLS: __thread SIGSEGV: altstack Notifications: epoll Architecture: amd64 Disabled: none Misc: softdebug LLVM: supported, not enabled. GC: Included Boehm (with typed GC and Parallel Mark)  root@falco:~/xsp-2.10.2# ./configure --prefix=/usr --sysconfdir=/etc/xsp root@falco:~/xsp-2.10.2# make && make install  root@falco:~# xsp4 --version xsp4.exe 2.10.2.0 Copyright (C) 2002-2011 Novell, Inc. Minimalistic web server for testing System.Web  root@falco:~# mkdir -p /var/www/asptest  root@falco:~# cd /var/www/asptest root@falco:/var/www/asptest# nano Default.aspx  <%@ Page language="C#" %> <html> <head> <title>Hello C#</title> </head> <body> <p><% Response.Write("Hello World");%></p> </body> </html> xsp was originally conceived as a test server, the daemon launch scripts are not there. We will correct this situation. Create the file /etc/default/xsp , and write variables to it by default: user=www-data group=www-data port=8080 address=0.0.0.0 /etc/init.d/xsp , give it execution rights ( chmod +x /etc/init.d/xsp ) and write to it: #!/bin/sh ### BEGIN INIT INFO # Provides: xsp # Required-Start: $local_fs $remote_fs $network # Required-Stop: $local_fs $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Asp.Net testing server startup script. # Description: Asp.Net testing server startup script. ### END INIT INFO PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC=xsp NAME=xsp DAEMON=/usr/bin/xsp4 DEFAULT=/etc/default/$NAME DAEMON_ARGS="--nonstop --root /var/www/asptest" #DAEMON_ARGS="--nonstop --root /usr/lib/xsp/test" MONO_SHARED_DIR=/var/run/$NAME PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME [ -x "$DAEMON" ] || exit 0 [ -f "$DEFAULT" ] && . $DEFAULT . /lib/lsb/init-functions if [ ! -e $MONO_SHARED_DIR ]; then mkdir $MONO_SHARED_DIR chown $user:$group $MONO_SHARED_DIR fi chk_start() { if [ -f "$PIDFILE" ]; then xpid=`head -1 "$PIDFILE"` xps=`ps -p $xpid | wc -l` if [ "$xps" != "1" ]; then log_action_msg "Xsp is running" return 1 fi fi return 0 } do_start() { export MONO_SHARED_DIR start-stop-daemon --start --background --make-pidfile \ --quiet --pidfile /var/run/$NAME.pid \ --user $user --group $group --chuid $user \ --exec $DAEMON -- \ --port $port --address $address \ $DAEMON_ARGS } do_stop() { if [ -e "$PIDFILE" ] ; then kill -9 `head -1 "$PIDFILE"` 1>/dev/null 2>&1 rm -f "$PIDFILE" fi } case "$1" in start) if chk_start ; then log_daemon_msg "Starting $DESC" "$NAME" do_start log_end_msg $? fi ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" do_stop log_end_msg $? ;; status) ;; restart|force-reload) log_daemon_msg "Restarting $DESC" "$NAME" do_stop do_start log_end_msg $? ;; *) echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 exit 3 ;; esac : xsp distribution, for a more complete picture. root@falco:~# update-rc.d xsp defaults root@falco:~# /etc/init.d/xsp start  root@falco:~# netstat -nlp | grep 8080 tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 20839/mono 

nginx settings in proxying accesses only for asp-files. The rest of the static files should be distributed by nginx . Without further thinking, let's take the configuration that Maxim Krentovsky proposed in his article and slightly modify it for us: server { listen 80; server_name serveraddr.ru; location / { root /var/www/asptest #root /usr/lib/xsp/test; index index.html index.htm index.aspx default.aspx Default.aspx; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.(aspx|asmx|ashx|axd|asax|ascx|soap|rem|axd|cs|config|dll)$ { root /var/www/asptest #root /usr/lib/xsp/test; proxy_pass http://127.0.0.1:8080; } } nginx best knows Google.

xsp best used for tests!Source: https://habr.com/ru/post/121159/
All Articles