Difference between revisions of "IT-SDK-Webserver"
Jump to navigation
Jump to search
Samerhijazi (talk | contribs) (→nginx) |
Samerhijazi (talk | contribs) (→Source) |
||
| (5 intermediate revisions by the same user not shown) | |||
| Line 3: | Line 3: | ||
* https://www.katacoda.com/courses/docker/create-nginx-static-web-server | * https://www.katacoda.com/courses/docker/create-nginx-static-web-server | ||
* http://nginx.org/en/docs/beginners_guide.html | * http://nginx.org/en/docs/beginners_guide.html | ||
| + | * https://torstenwalter.de/openshift/nginx/2017/08/04/nginx-on-openshift.html | ||
| + | |||
=nginx= | =nginx= | ||
* cfg-Base: /usr/share/nginx/html | * cfg-Base: /usr/share/nginx/html | ||
| Line 14: | Line 16: | ||
* List content of Directory: autoindex=on; | * List content of Directory: autoindex=on; | ||
<pre class="code"> | <pre class="code"> | ||
| − | nano Dockerfile | + | $ nano /etc/nginx/nginx.conf |
| + | -------------------------------------------------- | ||
| + | upstream backend { | ||
| + | server api:9000; | ||
| + | } | ||
| + | server { | ||
| + | listen 0.0.0.0:80; | ||
| + | index index.php index.html; | ||
| + | server_name web; | ||
| + | error_log "/opt/bitnami/nginx/logs/myapp-error.log"; | ||
| + | access_log "/opt/bitnami/nginx/logs/myapp-access.log"; | ||
| + | root /app; | ||
| + | location / { | ||
| + | try_files $uri $uri/index.php; | ||
| + | } | ||
| + | location ~ \.php$ { | ||
| + | # fastcgi_pass [PHP_FPM_LINK_NAME]:9000; | ||
| + | fastcgi_pass backend; | ||
| + | fastcgi_index index.php; | ||
| + | include fastcgi.conf; | ||
| + | } | ||
| + | } | ||
| + | -------------------------------------------------- | ||
| + | </pre> | ||
| + | <pre class="code"> | ||
| + | $ nano Dockerfile | ||
------------------------------------- | ------------------------------------- | ||
FROM nginx:alpine | FROM nginx:alpine | ||
COPY . /usr/share/nginx/html | COPY . /usr/share/nginx/html | ||
------------------------------------- | ------------------------------------- | ||
| − | docker build -t webserver-image:v1 . | + | $ docker build -t webserver-image:v1 . |
| − | docker run -d -p 80:80 webserver-image:v1 | + | $ docker run --rm -d -p 80:80 --name webserver-image webserver-image:v1 |
| − | curl localhost:80 | + | $ docker exec -it webserver-image |
| + | $ curl localhost:80 | ||
</pre> | </pre> | ||
Latest revision as of 15:57, 7 January 2021
Source
- https://stackoverflow.com/questions/55270099/how-do-i-build-a-custom-nginxalpine-based-container-listening-on-port-other-tha
- https://www.katacoda.com/courses/docker/create-nginx-static-web-server
- http://nginx.org/en/docs/beginners_guide.html
- https://torstenwalter.de/openshift/nginx/2017/08/04/nginx-on-openshift.html
nginx
- cfg-Base: /usr/share/nginx/html
- cfg-File: /etc/nginx/nginx.conf
- cfg-File: /etc/nginx/conf.d/default.conf
- cfg-Blocks: http, server, location
- cfg Location: /usr/local/nginx/conf, /usr/local/etc/nginx or /etc/nginx.
- control: nginx -s signal. Where signal may be the following: stop, quit, reload, reopen
- KILL: kill -s QUIT 1628
- List: ps -ax | grep nginx
- List content of Directory: autoindex=on;
$ nano /etc/nginx/nginx.conf
--------------------------------------------------
upstream backend {
server api:9000;
}
server {
listen 0.0.0.0:80;
index index.php index.html;
server_name web;
error_log "/opt/bitnami/nginx/logs/myapp-error.log";
access_log "/opt/bitnami/nginx/logs/myapp-access.log";
root /app;
location / {
try_files $uri $uri/index.php;
}
location ~ \.php$ {
# fastcgi_pass [PHP_FPM_LINK_NAME]:9000;
fastcgi_pass backend;
fastcgi_index index.php;
include fastcgi.conf;
}
}
--------------------------------------------------
$ nano Dockerfile ------------------------------------- FROM nginx:alpine COPY . /usr/share/nginx/html ------------------------------------- $ docker build -t webserver-image:v1 . $ docker run --rm -d -p 80:80 --name webserver-image webserver-image:v1 $ docker exec -it webserver-image $ curl localhost:80