Skip to content

Commit

Permalink
add nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
rsonghuster committed Jul 14, 2022
1 parent cf0ad09 commit 4a159b9
Show file tree
Hide file tree
Showing 11 changed files with 501 additions and 1 deletion.
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
> SSR 框架:
> - [nuxt-ssr](./web-framework/nodejs/custom-runtime/nuxt-ssr/src): `s init start-nuxt-ssr`
> Nginx 框架:
> - [nginx](./web-framework/nginx/src): `s init start-nginx`
> 为了对比Custom运行时和编程语言原生运行时的框架迁移区别,可以参考以下案例进行自行对比:
>
> | 框架名 | Custom运行时 | Node.js 12运行时 |
Expand Down
3 changes: 3 additions & 0 deletions readme_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ At present, this case repository contains the deployment cases of the following
> SSR frameworks
> - [nuxt-ssr](./web-framework/nodejs/custom-runtime/nuxt-ssr/src): `s init start-nuxt-ssr`
> Nginx:
> - [nginx](./web-framework/nginx/src): `s init start-nginx`
> In order to compare the framework migration differences between the Custom runtime and the programming language native runtime, you can refer to the following cases for your own comparison:
>
> | Framework name | Custom runtime | Node.js 12 runtime |
Expand Down
2 changes: 1 addition & 1 deletion update.list
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web-framework/nodejs/custom-runtime/nest
web-framework/nginx
26 changes: 26 additions & 0 deletions web-framework/nginx/hook/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
async function preInit(inputObj) {
console.log(`
Serverless Devs Application Case
Cloud services required:
- FC : https://fc.console.aliyun.com/
Tips:
- Serverless Devs Version >= v2.0.103
- FC Component: https://www.serverless-devs.com/fc/readme
`)
}

async function postInit(inputObj) {
console.log(`
* Before using, please check whether the actions command in Yaml file is available
* Carefully reading the notes in s.yaml is helpful for the use of the tool
* FC is only used as the execution environment, and the business code is in NAS
* If need help in the use process, please apply to join the Dingtalk Group: 33947367
`)
}

module.exports = {
postInit,
preInit
}
58 changes: 58 additions & 0 deletions web-framework/nginx/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Type: Application
Name: start-nginx
Provider:
- 阿里云
Version: 0.0.1
Description: 快速部署 nginx 到函数计算
HomePage: https://github.com/devsapp/start-web-framework
Tags:
- Web框架
- nginx
Category: Web框架
Service:
函数计算:
Authorities:
- AliyunFCFullAccess
Parameters:
type: object
additionalProperties: false # 不允许增加其他属性
required: # 必填项
- region
- serviceName
- functionName
properties:
region:
title: 地域
type: string
default: cn-hangzhou
description: 创建应用所在的地区
enum:
- cn-beijing
- cn-hangzhou
- cn-shanghai
- cn-qingdao
- cn-zhangjiakou
- cn-huhehaote
- cn-shenzhen
- cn-chengdu
- cn-hongkong
- ap-southeast-1
- ap-southeast-2
- ap-southeast-3
- ap-southeast-5
- ap-northeast-1
- eu-central-1
- eu-west-1
- us-west-1
- us-east-1
- ap-south-1
serviceName:
title: 服务名
type: string
default: web-framework
description: 服务名称,只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间
functionName:
title: 函数名
type: string
default: nginx
description: 函数名称,只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-64 之间
1 change: 1 addition & 0 deletions web-framework/nginx/readme.md
126 changes: 126 additions & 0 deletions web-framework/nginx/src/code/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@

#user nobody;
#Defines which Linux system user will own and run the Nginx server

worker_processes auto;
#Referes to single threaded process. Generally set to be equal to the number of CPUs or cores.

#error_log logs/error.log; #error_log logs/error.log notice;
#Specifies the file where server logs.

#pid logs/nginx.pid;
#nginx will write its master process ID(PID).

events {
worker_connections 1024;
# worker_processes and worker_connections allows you to calculate maxclients value:
# max_clients = worker_processes * worker_connections
}


http {
# anything written in /opt/nginx/conf/mime.types is interpreted as if written inside the http { } block
#

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;
# If serving locally stored static files, sendfile is essential to speed up the server,
# But if using as reverse proxy one can deactivate it

#tcp_nopush on;
# works opposite to tcp_nodelay. Instead of optimizing delays, it optimizes the amount of data sent at once.

#keepalive_timeout 0;
keepalive_timeout 900;
# timeout during which a keep-alive client connection will stay open.

#gzip on;
# tells the server to use on-the-fly gzip compression.

server {
# You would want to make a separate file with its own server block for each virtual domain
# on your server and then include them.
listen 9000;
#tells Nginx the hostname and the TCP port where it should listen for HTTP connections.
# listen 9000; is equivalent to listen *:9000;

server_name localhost;
# lets you doname-based virtual hosting

#charset koi8-r;

#access_log logs/host.access.log main;

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

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


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}
89 changes: 89 additions & 0 deletions web-framework/nginx/src/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# start-nginx 帮助文档

<p align="center" class="flex justify-center">
<a href="https://www.serverless-devs.com" class="ml-1">
<img src="http://editor.devsapp.cn/icon?package=start-nginx&type=packageType">
</a>
<a href="http://www.devsapp.cn/details.html?name=start-nginx" class="ml-1">
<img src="http://editor.devsapp.cn/icon?package=start-nginx&type=packageVersion">
</a>
<a href="http://www.devsapp.cn/details.html?name=start-nginx" class="ml-1">
<img src="http://editor.devsapp.cn/icon?package=start-nginx&type=packageDownload">
</a>
</p>

<description>

Z-Blog是由Z-Blog开发团队开发的一款小巧而强大的基于Asp和PHP平台的开源程序,致力于给用户提供优秀的博客写作体验

</description>

<table>

## 前期准备
使用该项目,推荐您拥有以下的产品权限 / 策略:

| 服务/业务 | 函数计算 | 硬盘挂载 | VPC | 其它 |
| --- | --- | --- | --- | --- |
| 权限/策略 | AliyunFCFullAccess | AliyunNASFullAccess | AliyunVPCFullAccess | AliyunECSFullAccess |

</table>

<codepre id="codepre">

# 代码 & 预览

- [ :smiley_cat: 源代码](https://github.com/devsapp/start-web-framework/blob/master/web-framework/nginx)

</codepre>

<deploy>

## 部署 & 体验

<appcenter>

- :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-nginx)
[![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-nginx) 该应用。

</appcenter>

- 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署:
- [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://www.serverless-devs.com/fc/config)
- 初始化项目:`s init start-nginx -d start-nginx`
- 进入项目,并进行项目部署:`cd start-nginx && s deploy -y`

</deploy>

<appdetail id="flushContent">

# 应用详情


本项目是将 nginx 部署到阿里云 Serverless 平台(函数计算 FC)。

通过 Serverless Devs 开发者工具,您只需要几步,就可以体验 Serverless 架构,带来的降本提效的技术红利。

部署完成之后,您可以看到系统返回给您的案例地址, 此时,打开案例地址,就可以进入 nginx 默认的首页:

![图片alt](https://img.alicdn.com/imgextra/i3/O1CN01C1yDPT1oBhA7JjW4y_!!6000000005187-2-tps-2090-666.png)



</appdetail>

<devgroup>

## 开发者社区

您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行:

<p align="center">

| <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407298906_20211028074819117230.png" width="130px" > | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407044136_20211028074404326599.png" width="130px" > | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407252200_20211028074732517533.png" width="130px" > |
|--- | --- | --- |
| <center>微信公众号:`serverless`</center> | <center>微信小助手:`xiaojiangwh`</center> | <center>钉钉交流群:`33947367`</center> |

</p>

</devgroup>
Loading

0 comments on commit 4a159b9

Please sign in to comment.