我正在嘗試在使用 Dockerfile 找到一些匹配項后撰寫新行,但它沒有按照我的代碼作業。我在下面解釋我的代碼。
/etc/nginx/conf.d/ubot-nginx.conf::
server {
listen 90;
server_name ubot_nginx;
location / {
# proxy_pass http://flask_app:5005;
try_files $uri @app;
# Do not change this
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 @app {
include uwsgi_params;
uwsgi_pass unix:///tmp/uwsgi.sock;
}
location /site {
# rewrite ^/static(.*) /$1 break;
# root /static;
alias /app/static/angular;
}
}
在上面的檔案,我需要寫一些新的生產線i.e-try_files $uri $uri/ /index.html =404;后,alias /app/static/angular;所以,我在我的使用以下命令Dockerfile。
RUN sed '/^alias /app/static/angular.*/a try_files $uri $uri/ /index.html =404;' /etc/nginx/conf.d/ubot-nginx.conf
我需要在這里當影像將構建上面給出的新行時,應該按照找到的特定匹配來撰寫,這在我的情況下沒有發生。請任何人都可以幫助我嗎?
uj5u.com熱心網友回復:
嘗試 sed -i -E 's|^(\s*alias /app/static/angular.*)|\1\n\ttry_files $uri $uri/ /index.html =404;|' /etc/nginx/conf.d/ubot-nginx.conf
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/390050.html
