
nginx
mkdir -p /db1/nginx/
cat >>/db1/nginx/nginx.conf << EOF
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_max_body_size 200m;
# 添加一个HTTPS server块
server {
listen 1700;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files \$uri \$uri/ /index.html;
}
location ^~ /api/ {
rewrite ^/api(/.*)\$ \$1 break;
proxy_pass http://8.141.154.17:2050;
# 传递请求头部信息
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
}
location ^~ /oss/ {
rewrite ^/oss(/.*)\$ \$1 break;
proxy_pass http://8.141.154.17:9001;
# 传递请求头部信息
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
EOF
```bash
mkdir -p /db1/nginx/html/
cat >>/db1/nginx/html/index.html << EOF
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
EOF
```bash
docker run -d --name nginx \
--network host \
-v /db1/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v /db1/nginx/:/usr/share/nginx \
nginx:stable-alpine3.19
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 程序员HoneyZ
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果