markdown NGINX Virtualhost

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown NGINX Virtualhost相关的知识,希望对你有一定的参考价值。

**MyPrestasi**  

```
server {
	listen 80;
	server_name myprestasi2.mampu.gov.my;
	return 301 https://$server_name$request_uri;
}
server {
	listen 443 ssl http2;
	# listen [::]:443 default_server;
	server_name myprestasi2.mampu.gov.my;
	
	root /var/www/myprestasi;

	client_max_body_size 5M;

	# Add index.php to the list if you are using PHP
	index index.php index.html index.htm index.nginx-debian.html;

	server_name myprestasi2.mampu.gov.my;
	
	ssl on;
	ssl_certificate /home/myprestasi2/ssl_cert/CertifcateBundle1.pem;
	ssl_certificate_key /home/myprestasi2/ssl_cert/myprestasi2.mampu.key;

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		 try_files $uri $uri/ /index.php?q=$uri&$args;
	}

	# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
	#
	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
	#
	#	# With php7.0-cgi alone:
	#	fastcgi_pass 127.0.0.1:9000;
	#	# With php7.0-fpm:
		fastcgi_pass unix:/run/php/php7.0-fpm.sock;
	}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	location ~ /\.ht {
		deny all;
	}


	# multi folders for agencies
	location /mampu {
		alias /var/www/myprestasi/mampu;
		try_files $uri $uri/ @mampu;
		#try_files $uri $uri/ /index.php?q=$uri&$args;

		#location ~ \.php$ {
         	#       include snippets/fastcgi-php.conf;
        	#
        	#       # With php7.0-cgi alone:
        	#       fastcgi_pass 127.0.0.1:9000;
        	#       # With php7.0-fpm:
                #	fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        	#}
	}

	location @mampu {
    		rewrite /mampu/(.*)$ /mampu/index.php?/$1 last;
	}	


	location /kkr {
                alias /var/www/myprestasi/kkr;
                try_files $uri $uri/ @kkr;
                #try_files $uri $uri/ /index.php?q=$uri&$args;

                #location ~ \.php$ {
                #       include snippets/fastcgi-php.conf;
                #
                #       # With php7.0-cgi alone:
                #       fastcgi_pass 127.0.0.1:9000;
                #       # With php7.0-fpm:
                #       fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                #}
        }

        location @kkr {
                rewrite /kkr/(.*)$ /kkr/index.php?/$1 last;
        }

}
```

以上是关于markdown NGINX Virtualhost的主要内容,如果未能解决你的问题,请参考以下文章

markdown nginx 搭建自己的图片服务器

markdown Nginx与WebSocket

markdown Ubuntu安装Nginx

markdown nginx代理

markdown https和nginx重定向

markdown Nginx的