[英]How do I modify nginx.conf when utilizing Docker?
I have inherited a Microsoft Visual Studio
MVC project for modification and I now need to allow users to upload files to the web server.我继承了一个
Microsoft Visual Studio
MVC 项目进行修改,我现在需要允许用户将文件上传到 web 服务器。 I utilize Windows 11
and IIS Express
from within MS Visual Studio
for development purposes and there is no issue with IIS.
我在
MS Visual Studio
中使用Windows 11
和IIS Express
用于开发目的, IIS.
However, the app runs in production on a Ubuntu-based
server running NGINX
as a web server.但是,该应用程序在
Ubuntu-based
服务器上运行,该服务器运行NGINX
作为 web 服务器。
PROBLEM: When I attempt to upload a file larger than 1MB from my browser to the production server I receive the error message "413 Request Entity Too Large."问题:当我尝试将大于 1MB 的文件从浏览器上传到生产服务器时,我收到错误消息“413 Request Entity Too Large”。 After scouring the web I have discovered: (a)
NGINX
invokes the 1MB limit by default;在搜索了 web 之后,我发现:(a)
NGINX
默认调用 1MB 限制; and (b) it is necessary to modify the nginx.conf
file by adding the NGINX
"client-max-body-size" directive. (b) 有必要通过添加
NGINX
“client-max-body-size”指令来修改nginx.conf
文件。
I have located the nginx.conf
file on the production server and have browsed it with Nano.
我在生产服务器上找到了
nginx.conf
文件,并用Nano.
However, I have stopped short of attempting to modify and save the file due to the presence of Docker.
但是,由于
Docker.
Admittedly, I know virtually nothing of Docker
and, unfortunately, the principals who set up this server have long since departed the Company.诚然,我对
Docker
几乎一无所知,不幸的是,设置此服务器的负责人早已离开公司。 Furthermore, it is unclear to me whether simply modifying the nginx.conf
file and restarting NGINX
on the production server will do the trick given what I presume to be the necessity to involve Docker.
此外,鉴于我认为有必要涉及 ZC5FD214CDD0D2B3B4272E73B202,我还不清楚是否简单地修改
nginx.conf
文件并在生产服务器上重新启动NGINX
是否可以Docker.
As an aside, my customer utilizes Azure DevOps
to facilitate collaboration.顺便说一句,我的客户利用
Azure DevOps
来促进协作。 I regularly stage changes to my project using Git
from within MS Visual Studio
and subsequently use a Ubuntu
update_app.sh
script to push the changes into production.我定期使用
MS Visual Studio
中的Git
对我的项目进行更改,随后使用Ubuntu
update_app.sh
脚本将更改推送到生产中。 I had previously attempted to modify the nginx.conf
file included with the local copy of my MVC project.我之前曾尝试修改我的 MVC 项目的本地副本中包含的
nginx.conf
文件。 The file was pushed via Azure DevOps
to the production server but the modified nginx.conf
file would not push to production, presumably due to the presence of Docker.
该文件通过
Azure DevOps
推送到生产服务器,但修改后的nginx.conf
文件不会推送到生产,可能是由于存在Docker.
I would appreciate someone providing me with an explanation of the interaction between Docker
and NGINX.
我很感激有人向我解释
Docker
和NGINX.
I would further appreciate any tip on how to get the modified nginx.conf
file pushed into production.我将进一步感谢有关如何将修改后的
nginx.conf
文件推入生产的任何提示。
Thanks in advance for your assistance.提前感谢你的帮助。
Thankfully this is pretty straightforward and NGIX has good documentation on this topic (see Copying Content and Configuration Files from the Docker Host section of Deploying NGINX and NGINX Plus on Docker ). Thankfully this is pretty straightforward and NGIX has good documentation on this topic (see Copying Content and Configuration Files from the Docker Host section of Deploying NGINX and NGINX Plus on Docker ).
Dockerfile
for the deployed solution (typically in project or solution root directory)Dockerfile
(通常在项目或解决方案根目录中)conf
within your source.conf
的目录。conf
and apply any changes to the configuration file.conf
中的 a 文件中,并对配置文件应用任何更改。Dockerfile
to copy files within conf
into the container where NGIX loads configuration files upon startup.Dockerfile
以将conf
中的文件复制到 NGIX 在启动时加载配置文件的容器中。 Add the following line into Dockerfile
after the line FROM ngix
(note: line may vary but should be obvious its using ngix
as base image): COPY conf {INSERT RELATIVE PATH TO CONF PARENT FOLDER}
FROM ngix
行之后将以下行添加到Dockerfile
中(注意:行可能会有所不同,但使用ngix
作为基础映像应该很明显): COPY conf {INSERT RELATIVE PATH TO CONF PARENT FOLDER}
This will copy your local configuration file into the container upon creation which NGIX will load upon startup.这将在创建时将您的本地配置文件复制到容器中,NGIX 将在启动时加载该容器。
Note : There are other solutions that support configuration changes without rebuilding the container.注意:还有其他解决方案支持配置更改而不重建容器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.