docker中nginx的目录进不去

修改docker的访问首页时,找不到对应的文件夹
图片说明

我哪里打错了吗,求指教

1个回答

你cat的是xml, cp的是html

qq_37746483
好小一只 眼睛花了。。。。,感谢
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Docker中nginx服务器端口问题

我在同一台服务器上安装两个宝塔面板,一个在Docker中,另一个没有使用Docker,我想让Docker中的网站和Docker外的网站同时使用80端口,该怎么实现?

使用Docker的Nginx 504网关超时

<div class="post-text" itemprop="text"> <p>I'm using PHP and Apache with nginx for a reverse proxy, all on Docker, and I have a couple of long running calls that are timing after 60 seconds, resulting in a 504 Gateway Time-out. I know my app is being called successfully because I'm tailing my PHP app's log and I can see it actively writing to the log. Every single time it's a 60 second timeout, but I can't seem to figure out where that setting is.</p> <p>I tried the suggestions in <a href="https://stackoverflow.com/questions/45252317/nginx-php-fpm-7-1-504-gateway-time-out">this post</a>, but nothing worked. I've updated my php.ini file with a few time related settings and I've verified they're being set with phpinfo</p> <pre><code>max_input_time = 0 max_execution_time = 500 </code></pre> <p>I also increased the memory limit to 512, but considering it times out in about 60 seconds every single time I don't think that's the issue.</p> <p>As far as updating nginx settings, I initially followed <a href="https://wiki.ssdt-ohio.org/display/rtd/Adjusting+nginx-proxy+Timeout+Configuration" rel="nofollow noreferrer">this tutorial</a> on adjusting nginx-proxy timeout, but that didn't work. I undid the changes, then ssh'd into the container and manually updated /etc/nginx/nginx.conf, here's what the http section looks like</p> <pre><code>http { include /etc/nginx/mime.types; default_type application/octet-stream; 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 /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 500; proxy_connect_timeout 600; proxy_send_timeout 600; send_timeout 600; client_max_body_size 5000; client_header_timeout 600; client_body_timeout 600; fastcgi_read_timeout 300; #gzip on; include /etc/nginx/conf.d/*.conf; } </code></pre> <p>I made sure to run <code>nginx -s reload</code> after updating the nginx.conf file. I'm not sure where else to look, because everything I've come across is pretty much what I've done already. What else could be causing nginx to timeout after 60 seconds? Thanks</p> <p>Here's my PHP dockerfile</p> <pre><code>FROM php:7.2-fpm-alpine3.7 RUN apk update; \ apk upgrade; RUN docker-php-ext-install pdo_mysql RUN apk add --no-cache php7-pear php7-dev gcc musl-dev make RUN pecl install xdebug RUN pecl install -o -f redis \ &amp;&amp; rm -rf /tmp/pear \ &amp;&amp; docker-php-ext-enable redis </code></pre> </div>

docker中nginx的日志记录时间与系统时间相差8小时

原来docker(Welcome to Alpine Linux 3.9)中的系统时间不是中国时区,经修改后,系统时间已确定修改为了中国时区后,重启了nginx服务,但nginx中的access.log日志记录的时间还是旧的时间,并不是新的中国时区时间,求教各位大佬怎么解决这个问题~ PS,这个docker是个公共组件,没法重启,一重启全恢复原状 有木有大佬回一下,555

docker获取镜像的时候报错:命令docker pull nginx

Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) ``` ```

docker 安装nginx+PHP 配置ssl无法启动

我按照这个大佬的方法搭建了PHP,也可以正常访问80端口。https://boke112.com/6402.html 可是我现在想在添加443,就无法启动了; **** ![图片说明](https://img-ask.csdn.net/upload/201912/14/1576323803_90931.png) 如上图:如果只保留第一个server,是可以正常访问的,添加下面第二个server就无法启动。 我的容器80端口和443端口都映射出来的,如下图: ![图片说明](https://img-ask.csdn.net/upload/201912/14/1576323992_911548.png) 请教过其他人有这样的说法: 我在只保留第一个server配置,不要第二个的时候,443也在监听:如下图 ![图片说明](https://img-ask.csdn.net/upload/201912/14/1576324141_524685.png) 当nginx无法启动时,那个443和80端口都没有了。 我想的是,docker安装ngixn时映射了443和80,所以启动就被监听,反之亦然。 如果是443监听的问题,就大佬指导一下,不是的话,也请指导一下。 ![图片说明](https://img-ask.csdn.net/upload/201912/14/1576324445_335987.jpg)

简单的Docker / Nginx错误 - PHP / Laravel

<div class="post-text" itemprop="text"> <p>I'm building a PHP and Laravel docker multi-container application by following <a href="https://medium.com/@shakyShane/laravel-docker-part-1-setup-for-development-e3daaefaf3c" rel="nofollow noreferrer">this tutorial</a>.</p> <p>It's straight forward and I followed it accurately but I'm running into the following error when running <code>docker-compose up</code>:</p> <pre><code>database_1 | 2018-07-08 16:51:11 1 [Note] mysqld: ready for connections. database_1 | Version: '5.6.40' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL) app_1 | [08-Jul-2018 15:02:52] NOTICE: fpm is running, pid 1 app_1 | [08-Jul-2018 16:51:10] NOTICE: ready to handle connections web_1 | 2018/07/08 16:52:24 [emerg] 1#1: unknown directive "listen:" in /etc/nginx/conf.d/default.conf:2 web_1 | nginx: [emerg] unknown directive "listen:" in /etc/nginx/conf.d/default.conf:2 see-number_web_1 exited with code 1 </code></pre> <p>The following is my <code>web.dockerfile</code> that handles the web/nginx service:</p> <pre><code>FROM nginx:1.10 ADD vhost.conf /etc/nginx/conf.d/default.conf </code></pre> <p>And this is the <code>vhost.conf</code> file which I'm using: </p> <pre><code>server { listen 80; index index.php index.html; root /var/www/public; location / { try_files $uri /index.php?$args; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass app:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } } </code></pre> <hr> <p>Here's the entire <code>docker-compose.yml</code> file holding it all together:</p> <pre><code>version: '2' services: # The Application app: build: context: ./ dockerfile: app.dockerfile working_dir: /var/www volumes: - ./:/var/www environment: - "DB_PORT=3306" - "DB_HOST=database" # The Web Server web: build: context: ./ dockerfile: web.dockerfile working_dir: /var/www volumes_from: - app ports: - 8080:80 # The Database database: image: mysql:5.6 volumes: - dbdata:/var/lib/mysql environment: - "MYSQL_DATABASE=homestead" - "MYSQL_USER=homestead" - "MYSQL_PASSWORD=secret" - "MYSQL_ROOT_PASSWORD=secret" ports: - "33061:3306" volumes: dbdata: </code></pre> <hr> <p>I found <a href="https://stackoverflow.com/a/21960803/6365534">this StackOverflow answer</a> that talks about hidden EOL characters but I've tried typing it out myself, and running it through <a href="https://www.textfixer.com/tools/remove-line-breaks.php" rel="nofollow noreferrer">this tool</a> in the same thread. </p> <p>Any suggestions as to why I might be getting this error?</p> <hr> <p><strong>Update 1</strong><br> As requested, I'm including the <code>docker history</code> for the web service image that's causing issues:</p> <pre><code>&lt;user&gt;:&lt;project&gt; &lt;user&gt;$ docker history see-number_web IMAGE CREATED CREATED BY SIZE COMMENT 5c0285cb9dd2 6 hours ago /bin/sh -c #(nop) ADD file:4387275b028088cf9… 453B 0346349a1a64 15 months ago /bin/sh -c #(nop) CMD ["nginx" "-g" "daemon… 0B &lt;missing&gt; 15 months ago /bin/sh -c #(nop) EXPOSE 443/tcp 80/tcp 0B &lt;missing&gt; 15 months ago /bin/sh -c ln -sf /dev/stdout /var/log/nginx… 22B &lt;missing&gt; 15 months ago /bin/sh -c apt-key adv --keyserver hkp://pgp… 58.2MB &lt;missing&gt; 15 months ago /bin/sh -c #(nop) ENV NGINX_VERSION=1.10.3-… 0B &lt;missing&gt; 15 months ago /bin/sh -c #(nop) MAINTAINER NGINX Docker M… 0B &lt;missing&gt; 15 months ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B &lt;missing&gt; 15 months ago /bin/sh -c #(nop) ADD file:4eedf861fb567fffb… 123MB </code></pre> </div>

Docker nginx和Go(Golang)是独立的容器。 Nginx配置

<div class="post-text" itemprop="text"> <p>On my localhost I've got Docker with 2 containers: Nginx and Golang. I want to do request from my local machine and get response from Go (localhost -&gt; Nginx -&gt; Go). </p> <p>Containers work. I can go into Nginx container and run <code>curl -v 'test:8080/path' -d "param1=value1&amp;param2=value2"</code> and I've got correct response. </p> <p>But If I try to run the same request from host machine I've got an error - 502 Bad Gateway. If I change request and run <code>curl -v -X POST 'test:8080/path'</code> (same request without data) - It's ok. </p> <p>My Nginx config:</p> <pre><code>server { listen 80; server_name test; client_max_body_size 20M; charset utf8; location / { proxy_pass http://go:8000; // there go - docker compose link } } </code></pre> <p>I think, problem in Nginx configuration. But I'm newbie with nginx. Plz, help me :)</p> </div>

docker nginx 502坏网关

<div class="post-text" itemprop="text"> <p>I was trying to change the port number in both nginx.conf and docker-compose.yml to 9001 instead 9000. However, when I run docker-compose up, it shows 502 Bad Gateway. Why is that? am I locked to use port 9000 only? </p> <p><strong>nginx.conf</strong></p> <pre><code>location /index.php { include fastcgi_params; fastcgi_connect_timeout 10s; fastcgi_read_timeout 10s; fastcgi_buffers 256 4k; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass php:9000; &lt;-- Changing this to 9001 } </code></pre> <p><strong>docker-compose.yml</strong></p> <pre><code>php: build: images/php volumes: - ./images/php/app:/app working_dir: /app/public command: php-fpm links: - db - cache ports: - "9000:9000" &lt;-- Changing this to "9001:9001" </code></pre> </div>

Docker nginx&fpm:我的nginx错误404

<div class="post-text" itemprop="text"> <p>I try to run a php application with fpm for <a href="https://github.com/ellakcy/docker-moodle/tree/dev" rel="nofollow noreferrer">this</a> project. And I am trying to make the nginx image to run the fpm based solution. My <code>docker-compose.yml</code> is:</p> <pre class="lang-yml prettyprint-override"><code>version: '2' services: # apache based images # A base image for apache - based moodle builds moodle_apache_base: build: context: . dockerfile: dockerfiles/apache/Dockerfile_base image: ellakcy/moodle:apache_base # Mysql running variant moodle_mysql_db: image: mysql environment: MYSQL_RANDOM_ROOT_PASSWORD: "yes" MYSQL_ONETIME_PASSWORD: "yes" MYSQL_DATABASE: "${MOODLE_DB_NAME}" MYSQL_USER: '${MOODLE_MYSQL_USER}' MYSQL_PASSWORD: '${MOODLE_MYSQL_PASSWORD}' moodle_mysql: build: context: . dockerfile: dockerfiles/apache/Dockerfile_mysql image: ellakcy/moodle:mysql_maria_apache links: - "moodle_mysql_db:moodle_db" - "moodle_apache_base" ports: - "6080:80" environment: MOODLE_DB_HOST: "moodle_mysql_db" MOODLE_DB_NAME: "${MOODLE_DB_NAME}" MOODLE_DB_USER: '${MOODLE_MYSQL_USER}' MOODLE_DB_PASSWORD: "${MOODLE_MYSQL_PASSWORD}" MOODLE_ADMIN: "${MOODLE_ADMIN}" MOODLE_ADMIN_PASSWORD: "${MOODLE_ADMIN_PASSWORD}" MOODLE_URL: "http://0.0.0.0:6080" # postgresql running variant moodle_psql_db: image: postgres environment: POSTGRES_DB: "${MOODLE_DB_NAME}" POSTGRES_USER: '${MOODLE_MYSQL_USER}' POSTGRES_PASSWORD: '${MOODLE_MYSQL_PASSWORD}' moodle_psql: build: context: . dockerfile: dockerfiles/apache/Dockerfile_postgrtesql image: ellakcy/moodle:postgresql_apache links: - "moodle_psql_db:moodle_db" - "moodle_apache_base" ports: - "6082:80" environment: MOODLE_DB_HOST: "moodle_psql_db" MOODLE_DB_NAME: "${MOODLE_DB_NAME}" MOODLE_DB_USER: '${MOODLE_MYSQL_USER}' MOODLE_DB_PASSWORD: "${MOODLE_MYSQL_PASSWORD}" MOODLE_ADMIN: "${MOODLE_ADMIN}" MOODLE_ADMIN_PASSWORD: "${MOODLE_ADMIN_PASSWORD}" MOODLE_URL: "http://0.0.0.0:6082" # Testing mariadb support moodle_maria_db: image: mariadb environment: MYSQL_RANDOM_ROOT_PASSWORD: "yes" MYSQL_ONETIME_PASSWORD: "yes" MYSQL_DATABASE: "${MOODLE_DB_NAME}" MYSQL_USER: '${MOODLE_MYSQL_USER}' MYSQL_PASSWORD: '${MOODLE_MYSQL_PASSWORD}' moodle_maria: image: ellakcy/moodle:mysql_maria_apache links: - "moodle_mysql" - "moodle_maria_db:moodle_db" ports: - "6081:80" environment: MOODLE_DB_HOST: "moodle_maria_db" MOODLE_DB_NAME: "${MOODLE_DB_NAME}" MOODLE_DB_USER: '${MOODLE_MYSQL_USER}' MOODLE_DB_PASSWORD: "${MOODLE_MYSQL_PASSWORD}" MOODLE_ADMIN: "${MOODLE_ADMIN}" MOODLE_ADMIN_PASSWORD: "${MOODLE_ADMIN_PASSWORD}" MOODLE_URL: "http://0.0.0.0:6081" #Alpine fpm based images #Basic alpine fpm image alpine_fpm_base: build: context: . dockerfile: dockerfiles/fpm_alpine/Dockerfile_base image: ellakcy/moodle:alpine_fpm_base moodle_mysql_alpine_db: image: mysql environment: MYSQL_RANDOM_ROOT_PASSWORD: "yes" MYSQL_ONETIME_PASSWORD: "yes" MYSQL_DATABASE: "${MOODLE_DB_NAME}" MYSQL_USER: '${MOODLE_MYSQL_USER}' MYSQL_PASSWORD: '${MOODLE_MYSQL_PASSWORD}' # Mysql Enabled image nginx: image: nginx:alpine ports: - "7070:80" volumes: - './conf/nginx/nginx.conf:/etc/nginx/nginx.conf:ro' links: - 'moodle_mysql_alpine' volumes_from: - 'moodle_mysql_alpine' moodle_mysql_alpine: build: context: . dockerfile: dockerfiles/fpm_alpine/Dockerfile_mysql image: ellakcy/moodle:mysql_maria_fpm_alpine links: - "moodle_mysql_alpine_db:moodle_db" - "alpine_fpm_base" environment: MOODLE_DB_HOST: "moodle_mysql_alpine_db" MOODLE_DB_NAME: "${MOODLE_DB_NAME}" MOODLE_DB_USER: '${MOODLE_MYSQL_USER}' MOODLE_DB_PASSWORD: "${MOODLE_MYSQL_PASSWORD}" MOODLE_ADMIN: "${MOODLE_ADMIN}" MOODLE_ADMIN_PASSWORD: "${MOODLE_ADMIN_PASSWORD}" MOODLE_URL: "http://0.0.0.0:7070/moodle_mysql" </code></pre> <p>And the nginx configuration is:</p> <pre><code>events { worker_connections 768; } http { include /etc/nginx/mime.types; default_type application/octet-stream; charset utf-8; gzip on; gzip_disable "msie6"; client_max_body_size 10000M; server { listen 80; root /var/www/www; index index.php; location / { try_files $uri $uri/ =404; } location ~ \.php$ { fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_read_timeout 600; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_intercept_errors on; fastcgi_index index.php; fastcgi_pass moodle_mysql_alpine:9000; } } } </code></pre> <p>But regardless what I've tried to do is useless I cannot make my <code>moodle_mysql_alpine</code> to get served via nginx. Do you fellows have an Idea how I can make it to get served? Also keep in minf that I do not care to keep volumes in my local filesysytem bevcause this file is intended to build and run the images just to upload them to an image repository.</p> </div>

nginx,docker和静态内容

<div class="post-text" itemprop="text"> <p>I'm serving wordpress for most urls, and static content for a lot of legacy content. Everything under one domain name. Wordpress is served out of docker, via a proxy pass. Static files are just from a unique root.</p> <pre><code>location @docker { proxy_pass http://127.0.0.1:8007; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Accept-Encoding ""; proxy_set_header Proxy ""; } location / { include /etc/nginx/snippets/maritime_static_site.conf; root /mnt/code/maritime/maritime-static; #try_files $uri $uri/index.html $uri/index.htm $uri/index.php @docker; try_files $uri @docker; auth_basic "Private Beta"; auth_basic_user_file /etc/nginx/.htpasswd-maritime; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/run/php/php7.0-fpm.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } </code></pre> <p>Static html, static php, and images are working. Wordpress is working. Wordpress admin (/wp-admin &amp; wp-login.php) are giving file not found. I'm guessing it's trying files from the static root location. Any ideas how I can fix this?</p> </div>

权限被拒绝Nginx Docker

<div class="post-text" itemprop="text"> <p>I'm using docker compose to boot up a development workspace, consisting of php, nginx and mysql. Everything boots, static html get's served, but when trying to start a laravel app, i get the following error:</p> <blockquote> <p>The stream or file "/home/html/storage/logs/laravel-2019-06-10.log" could not be opened: failed to open stream: Permission denied</p> </blockquote> <p>I searched around and it looked like a permissions issue? Do note, that the docker with just the database and the build in php server does seem to work.</p> <p>My docker-compose.yml</p> <pre><code>version: "3" services: db: image: mysql command: --default-authentication-plugin=mysql_native_password restart: always environment: MYSQL_ROOT_PASSWORD: "root" ports: - 3306:3306 php-fpm: image: php:7.3-fpm-alpine links: - db volumes: - "./:/home/html/" nginx: image: nginx:1-alpine ports: - "8080:80" links: - php-fpm volumes: - "./site.conf:/etc/nginx/conf.d/default.conf" - "./:/home/html/" </code></pre> <p>My nginx config:</p> <pre><code>server { index index.php index.html; listen 80 default_server; error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; root /home/html/public; location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass php-fpm:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } } </code></pre> <p>Kind regards :)</p> </div>

Docker Nginx 502 GET / Post请求的网关不正确,但Websocket无效

<div class="post-text" itemprop="text"> <p>There have been various similar cases here on stackoverflow but they're pretty much all refer to incorrect ports or using localhost as the IP instead of the docker-machine ip.</p> <p>The vue.js app connects perfectly fine to the websocket and works. However, the GET requests to <code>192.168.99.100:8080/meows</code> and other endpoints all hit the <code>nginx 502 bad gateway</code>. Manually accessing the endpoints (instead of vue.js) also hit <code>502 bad gateway</code>.</p> <p>The ip's are properly set. Ports are the same everywhere <code>:8080</code>. endpoints have the correct <code>http verb</code>and all have an <code>nginx upstream</code> pointing at the <code>server location /..{}</code>. Yet no problems connecting to the network, all data passing through no problem.</p> <p>EDIT: Im running windows 7 with the docker-toolbox because my windows version doesnt have the whole virtualization thing. No further configuration after installation has been done.</p> <p>The architecture is the following:</p> <p><a href="https://i.stack.imgur.com/NRVxE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NRVxE.jpg" alt="enter image description here"></a></p> <p>docker-compose</p> <pre><code>version: "3.6" services: meow: build: "." command: "meow-service" depends_on: - "postgres" - "nats" environment: POSTGRES_DB: "meower" POSTGRES_USER: "meower" POSTGRES_PASSWORD: "123456" NATS_ADDRESS: "nats:4222" query: build: "." command: "query-service" depends_on: - "postgres" - "nats" environment: POSTGRES_DB: "meower" POSTGRES_USER: "meower" POSTGRES_PASSWORD: "123456" NATS_ADDRESS: "nats:4222" ELASTICSEARCH_ADDRESS: "elasticsearch:9200" pusher: build: "." command: "pusher-service" depends_on: - "nats" environment: NATS_ADDRESS: "nats:4222" postgres: build: "./postgres" restart: "always" environment: POSTGRES_DB: "meower" POSTGRES_USER: "meower" POSTGRES_PASSWORD: "123456" nats: image: "nats-streaming:0.9.2" restart: "always" elasticsearch: image: 'docker.elastic.co/elasticsearch/elasticsearch:6.2.3' nginx: build: "./nginx" ports: - "8080:80" depends_on: - "meow" - "query" - "pusher" </code></pre> <p>nginx.conf:</p> <pre><code>user nginx; worker_processes 1; events { worker_connections 1024; } http { upstream meows_POST { server meow:8080; } upstream meows_GET { server query:8080; } upstream search_GET { server query:8080; } upstream pusher { server pusher:8080; } server { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; add_header Access-Control-Allow-Origin *; location /meows { limit_except GET POST OPTIONS { deny all; } proxy_pass http://meows_$request_method; } location /search { limit_except GET OPTIONS { deny all; } proxy_pass http://search_GET; } location /pusher { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_pass http://pusher; } } } </code></pre> <p>And to show that the go application also uses the correct ports, the following is the port listening for </p> <pre><code>func newRouter() (router *mux.Router) { router = mux.NewRouter() router.HandleFunc("/meows", listMeowsHandler). Methods("GET") router.HandleFunc("/search", searchMeowsHandler). Methods("GET") return } router := newRouter() if err := http.ListenAndServe(":8080", router); err != nil { log.Fatal(err) } </code></pre> </div>

在Docker中通过Nginx实现PHP的多个版本

<div class="post-text" itemprop="text"> <p>I run two docker containers for PHP5.6:</p> <pre><code>docker run --name php5 \ -v /html1:/var/www/html/site1 \ -d -p 9001:9000 php:5.6-fpm </code></pre> <p>And for PHP7:</p> <pre><code>docker run --name php7 \ -v /html2:/var/www/html/site2 \ -d -p 9000:9000 php:7-fpm </code></pre> <p>I run Docker container with Nginx:</p> <pre><code>docker run --name nginx-cache \ -v /nginx.conf:/etc/nginx/nginx.conf \ -v /nginx/html1:/var/www/html/site1 \ -v /nginx/html2:/var/www/html/site2 \ -v /sites-enabled:/etc/nginx/sites-enabled/ \ --link php5 --link php7 -d -p 9999:80 nginx </code></pre> <p>with <code>nginx.conf</code>:</p> <pre><code>user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { sendfile on; gzip on; gzip_http_version 1.0; gzip_proxied any; gzip_min_length 500; gzip_disable "MSIE [1-6]\."; gzip_types text/plain text/xml text/css text/comma-separated-values text/javascript application/x-javascript application/atom+xml; gzip_disable "msie6"; ## # Basic Settings ## server_names_hash_bucket_size 64; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; client_body_buffer_size 128k; include /etc/nginx/mime.types; default_type application/octet-stream; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } </code></pre> <p>with site1 config:</p> <pre><code>server { listen 80 default_server; server_name site1; root /var/www/html/site1/; index index.php index.html index.htm default.html default.htm; fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; fastcgi_read_timeout 180; location ~ \.php$ { fastcgi_pass php5:9001; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SERVER_NAME $server_name; } } </code></pre> <p>and site2 config:</p> <pre><code>server { listen 80; server_name site2; root /var/www/html/site2/; index index.php index.html index.htm default.html default.htm; fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; fastcgi_read_timeout 180; location ~ \.php$ { fastcgi_pass php7:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SERVER_NAME $server_name; } } </code></pre> <p>This request to site2 is 200 OK with proper response:</p> <pre><code>curl -X GET \ http://localhost:9999/index.php \ -H 'host: site2' </code></pre> <p>And for the request to site1:</p> <pre><code>curl -X GET \ http://localhost:9999/index.php \ -H 'host: site1' </code></pre> <p>In the Nginx container logs I always see:</p> <blockquote> <p>2017/04/26 21:18:27 [error] 7#7: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.17.0.1, server: site1, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://172.17.0.3:9001", host: "site1"</p> </blockquote> <p>Any ideas how to troubleshoot this would be highly appreciated. </p> </div>

Docker - Nginx + PHP-FPM =达到超时

<div class="post-text" itemprop="text"> <p>Simple question: I'm getting <code>Maximum execution time of 0 seconds exceeded</code>, but I don't know why: there are a lot of things written about it, but in script I've no set_timeout or anything like that, just in PHP-FPM config I've <code>php_value[max_execution_time] = 0</code> and even with this I'm gettting timeout from PHP-FPM's side (nginx is OK, no 504 Gateway Timeout or what's throwing). The thing is long running http request being killed in aprox. 3 mins. Setup is standard nginx + php-fpm (7.2) running in docker.</p> <p>Thanks for any points!</p> </div>

Docker(NGINX,PHP,mySQL)和Windows - 文件权限

<div class="post-text" itemprop="text"> <p>I've been looking into docker for a few hours; I'm running Windows 8.1 as the host machine, and VirtualBox with boot2docker.</p> <p>This is my docker-compose.yml:</p> <pre><code>mysql: image: mysql ports: - "6603:3306" environment: MYSQL_ROOT_PASSWORD: mysql MYSQL_USER: mysql fpm: image: php:7.0.2-fpm volumes: - /c/Users/Administrator/www:/var/www/html ports: - "9000:9000" links: - mysql nginx: image: nginx ports: - "80:80" - "443:443" volumes: - /c/Users/Administrator/www:/var/www/html links: - fpm </code></pre> <p>This works fine (I can go to my docker ip address and see the nginx welcome page); although when I run mkdir for example (through php) it will give an error regarding windows permissions.</p> </div>

Docker撰写:Nginx和PHP-FPM无法正常工作

<div class="post-text" itemprop="text"> <p>I'm testing docker compose with Nginx and php-fpm, but this fail. My docker-compose.yml:</p> <pre><code>version: '2' services: nginx: container_name: nginx build: context: ./dockerfiles/nginx/ dockerfile: Dockerfile volumes: - ./project/:/usr/share/nginx/html/ ports: - "8000:80" links: - php php: container_name: php-fpm image: php:7-fpm volumes: - ./project/:/var/www/html/ ports: - "9000:9000" </code></pre> <p>This is my dockerfile Nginx:</p> <pre><code>FROM nginx:latest COPY config/default.conf /etc/nginx/conf.d/ </code></pre> <p>And dafault.conf file:</p> <pre><code>server { listen 80; server_name localhost; root /usr/share/nginx/html; location / { try_files $uri /index.php$is_args$args; } location ~ ^/.+\.php(/|$) { fastcgi_pass php:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } } </code></pre> <p>when I try localhost: 8000 returns the following message:</p> <p>"File not found."</p> <p>but, the index.php is in the project/ path.</p> <p>that I am wrong?</p> </div>

Docker nginx + php-fpm配置主机?

<div class="post-text" itemprop="text"> <p>I am trying to set up a work environment for myself. I can’t get to the server through the name specified in hosts file.</p> <p>docker-compose.yml:</p> <pre><code>version: '2' services: nginx: image: nginx:latest ports: - "80:80" - "443:443" volumes: - ./hosts:/etc/nginx/conf.d - ./www:/var/www - ./logs:/var/log/nginx links: - php php: build: ./images/php links: - mysql volumes: - ./www:/var/www mysql: image: mysql:8 ports: - "3306:3306" volumes: - ./mysql:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: secret </code></pre> <p>php dockerfile:</p> <pre><code>FROM php:7.1-fpm RUN apt-get update &amp;&amp; apt-get install -y \ curl \ wget \ git \ libfreetype6-dev \ libjpeg62-turbo-dev \ libmcrypt-dev \ libpng-dev \ &amp;&amp; docker-php-ext-install -j$(nproc) iconv mcrypt mbstring mysqli pdo_mysql zip \ &amp;&amp; docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ &amp;&amp; docker-php-ext-install -j$(nproc) gd RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer ADD php.ini /usr/local/etc/php/conf.d/40-custom.ini WORKDIR /var/www CMD ["php-fpm"] </code></pre> <p>./hosts/hello-dev.conf:</p> <pre><code>server { server_name hello.dev; listen 80; index index.php; set $MAGE_ROOT /var/www/hello.dev; error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; root $MAGE_ROOT; location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass php:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } } </code></pre> <p>hosts: <code>127.0.0.1 hello.dev</code></p> <p>Tell me what you can try to do in this situation? If I go to the address <a href="http://127.0.0.1" rel="nofollow noreferrer">http://127.0.0.1</a> it opens the site, but I need to be able to create several configs with different names.</p> </div>

Nginx反向代理到Golang服务器的Docker问题

<div class="post-text" itemprop="text"> <p>I have nginx reverse proxying to a golang server, each in its own docker container and running normally. I keep getting this error in nginx when trying to connect to Go container, BOTH on my local Mac machine and on the production server Linux Debian. It was working on my local Mac machine a week ago and all of a sudden it doesn't anymore</p> <pre><code>nginx_1 | 2017/09/28 01:29:54 [error] 5#5: *12 upstream timed out (110: Connection timed out) while connecting to upstream, client: 172.23.0.1, server: , request: "GET /api/about HTTP/1.1", upstream: "http://67.199.248.12:8080/api/about", host: "localhost" </code></pre> <p>can someone explain what's going on here? What is 67.199.248.12 and why isn't Nginx able to ping/connect to the Go container?</p> <p>here's what's inside /etc/hosts in Go container</p> <pre><code>127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 172.23.0.5 31f4103f002c </code></pre> <p>here's my nginx.conf</p> <pre><code>upstream gogo { server go:8080 weight=10 max_fails=3 fail_timeout=30s; } server { listen 80; location /api/ { resolver 127.0.0.1 valid=30s; proxy_pass http://gogo; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; } } </code></pre> <p>I'm using docker-compose v3 to run nginx and docker</p> <pre><code> nginx: restart: always image: nginx volumes: - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf ports: - "80:80" command: /bin/bash -c "nginx -g 'daemon off;'" go: build: context: ./api expose: - "8080" depends_on: - nginx </code></pre> <p>go code:</p> <pre><code>func main() { router := mux.NewRouter().StrictSlash(true) router.HandleFunc("/api/about", About).Methods("GET") log.Fatal(http.ListenAndServe(":8080", router)) } </code></pre> </div>

在docker的上游找不到Docker + Nginx主机

<div class="post-text" itemprop="text"> <p>I'm trying to run Nginx and PHP-FPM containers with network_mode: host in docker-compose, when defining a network_mode as "bridge" it works fine, but when defining network_mode as "host" I receive :</p> <p>nginx: [emerg] host not found in upstream "ui" in /etc/nginx/conf.d/ui.conf:10</p> <p>Everything works fine when setting network_mode to bridge, unfortunately I need to set it to host, as I need access to host network so I can access ueye camera.</p> <p>This is my docker-compose file </p> <pre><code>version: '3' services: nginx: image: nginx:alpine container_name: nginx tty: true ports: - "80:80" - "443:443" - "8000:8000" volumes: - ./../../ui/:/var/www/ - ./nginx/:/etc/nginx/conf.d/ network_mode: host depends_on: - ui restart: always ui: build: context: ./../../ui dockerfile: Dockerfile volumes: - ./../../ui/:/var/www/ container_name: ui tty: true environment: SERVICE_NAME: ui working_dir: /var/www network_mode: host ports: - "9000:9000" </code></pre> <p>The nginx conf file </p> <pre><code>server { listen 80; index index.php index.html; error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; root /var/www/public; location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass ui:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } location / { try_files $uri $uri/ /index.php?$query_string; gzip_static on; } } </code></pre> </div>

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

再不跳槽,应届毕业生拿的都比我多了!

跳槽几乎是每个人职业生涯的一部分,很多HR说“三年两跳”已经是一个跳槽频繁与否的阈值了,可为什么市面上有很多程序员不到一年就跳槽呢?他们不担心影响履历吗? PayScale之前发布的**《员工最短任期公司排行榜》中,两家码农大厂Amazon和Google**,以1年和1.1年的员工任期中位数分列第二、第四名。 PayScale:员工最短任期公司排行榜 意外的是,任期中位数极小的这两家公司,薪资...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

数据库——玩转SQL语句(以MySQL为例)

一、前言 照着大学的SQL server来学

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

华为初面+综合面试(Java技术面)附上面试题

华为面试整体流程大致分为笔试,性格测试,面试,综合面试,回学校等结果。笔试来说,华为的难度较中等,选择题难度和网易腾讯差不多。最后的代码题,相比下来就简单很多,一共3道题目,前2题很容易就AC,题目已经记不太清楚,不过难度确实不大。最后一题最后提交的代码过了75%的样例,一直没有发现剩下的25%可能存在什么坑。 笔试部分太久远,我就不怎么回忆了。直接将面试。 面试 如果说腾讯的面试是挥金如土...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

程序员写出这样的代码,能不挨骂吗?

当你换槽填坑时,面对一个新的环境。能够快速熟练,上手实现业务需求是关键。但是,哪些因素会影响你快速上手呢?是原有代码写的不够好?还是注释写的不够好?昨夜...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

HTTP与HTTPS的区别

面试官问HTTP与HTTPS的区别,我这样回答让他竖起大拇指!

程序员毕业去大公司好还是小公司好?

虽然大公司并不是人人都能进,但我仍建议还未毕业的同学,尽力地通过校招向大公司挤,但凡挤进去,你这一生会容易很多。 大公司哪里好?没能进大公司怎么办?答案都在这里了,记得帮我点赞哦。 目录: 技术氛围 内部晋升与跳槽 啥也没学会,公司倒闭了? 不同的人脉圈,注定会有不同的结果 没能去大厂怎么办? 一、技术氛围 纵观整个程序员技术领域,哪个在行业有所名气的大牛,不是在大厂? 而且众所...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

01、Java入门(Getting Started);02、集成开发环境(IDE);03、项目结构(Eclipse JavaProject);04、类和对象(Classes and Objects);05:词法结构(Lexical Structure);06:数据类型和变量(Data Type and Variables);07:运算符(Operators);08:控制流程语句(Control Flow Statements);

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

立即提问
相关内容推荐