Docker中nginx服务器端口问题

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

2个回答

服务器上安装Nginx,然后它作为最前面的侦听80端口,然后根据访问的路径,来把请求转发到运行在docker的程序,还是没有运行在docker的程序。

用nginx的反向代理呢,比如域名1直接反向代理到物理机的80端口,域名2反向代理到物理机的另一个端口,然后映射到docker的80端口

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
docker中nginx的目录进不去

修改docker的访问首页时,找不到对应的文件夹 ![图片说明](https://img-ask.csdn.net/upload/201811/08/1541660367_472307.png) 我哪里打错了吗,求指教

使用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获取镜像的时候报错:命令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 / 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的日志记录时间与系统时间相差8小时

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

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和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&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反向代理进行服务器

<div class="post-text" itemprop="text"> <p>I've been trying to set up a go web application with docker and nginx as a reverse proxy.</p> <p>My plan is to use a single domain for multiple applications e.g.: <code>mydomain.com/myapp1</code>.</p> <p>However whenever I try to access my app in with an url like <code>localhost/myapp/something</code>, the request is redirected to <code>http://localhost/something</code>. </p> <p>I've gone through all kinds of nginx configs, none of them worked, so I suspect that the problem is on the go side.</p> <p>In the app itself, I'm using gorilla mux for routing, and also negroni for some middleware.</p> <p>The relevant code looks something like this:</p> <pre><code>baseRouter := mux.NewRouter() baseRouter.HandleFunc("/something", routes.SomeHandler).Methods("GET") baseRouter.HandleFunc("/", routes.IndexHandler).Methods("GET") commonMiddleware := negroni.New( negroni.HandlerFunc(middleware.Debug), ) commonMiddleware.UseHandler(baseRouter) log.Fatal(http.ListenAndServe(":5600", commonMiddleware)) </code></pre> <p>According to this, every request should go through my debug middleware, which just prints some request info to stdout, however when the redirects happen, it doesn't work.</p> <p>But if the path doesn't match any handlers, everything works just fine, the standard go 404 message appears as expected, and the request is printed by the debug middleware as well.</p> <p>My GET handlers generally only do something like this: </p> <pre><code>templ, _ := template.ParseFiles("public/something.html") templ.Execute(w, utils.SomeTemplate{ Title: "something", }) </code></pre> <p>And finally, the relevant part in my nginx config:</p> <pre><code>server { listen 80; server_name localhost; location /myapp/ { # address "myapp" is set by docker-compose proxy_pass http://myapp:5600/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; 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_cache_bypass $http_upgrade; } } </code></pre> <p>This kind of nginx config used to be enough for nodeJS apps in the past, so I don't understand why it wouldn't work. If anyone could point out what the hell I'm doing wrongly, I would appreciate it a lot.</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>

权限被拒绝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宿主机随机端口映射了docker容器,如何让docker容器知道宿主机的IP与映射端口呢?

本人使用springcloud+docker的结构搭建微服务,现在遇到的问题是: docker宿主机使用-P命令随机端口绑定的docker指定端口(比如每个容器都暴露8080端口), 但是容器中无法知道宿主机的ip和映射端口,即eureka上的实例不知道暴露给外部的什么访问IP和端口(宿主机IP和宿主机port)。 请教各位大神,此问题该如何解决,谢谢! **【docker显示宿主机的随机端口32773映射了容器8080端口】** ![图片说明](https://img-ask.csdn.net/upload/201908/11/1565453714_366300.png) **【Eureka显示是容器端口8080,而非宿主机映射端口】** ![图片说明](https://img-ask.csdn.net/upload/201908/11/1565453818_448472.png)

docker 构建相同的两个镜像是否会提高服务器性能

现在服务器构建两个tomcat镜像,映射端口分别为88,89。 服务器安装了nginx,假如 同时进来1000个请求,理论上分别分配给每个tomcat镜像500请求。 那么这种做法会起到提高性能的目的吗?还是和 我在服务器构建一个tomcat镜像的性能效果相同。

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>

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>

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 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>

什么情况下nginx会发生端口丢失

SLB外网映射了一个8083端口,阿里云SLB+Nginx(监听80)的,请求后端后无法成功返回,curl后发现端口丢失,在nginx里增加了端口可以成功返回。问题是解决了但是不知道导致这个问题的原因是什么,望各位大神解答一下,谢谢。

在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>

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

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

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

和黑客斗争的 6 天!

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

Intellij IDEA 实用插件安利

1. 前言从2020 年 JVM 生态报告解读 可以看出Intellij IDEA 目前已经稳坐 Java IDE 头把交椅。而且统计得出付费用户已经超过了八成(国外统计)。IDEA 的...

搜狗输入法也在挑战国人的智商!

故事总是一个接着一个到来...上周写完《鲁大师已经彻底沦为一款垃圾流氓软件!》这篇文章之后,鲁大师的市场工作人员就找到了我,希望把这篇文章删除掉。经过一番沟通我先把这篇文章从公号中删除了...

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

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

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

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

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

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

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

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

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

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

魂迁光刻,梦绕芯片,中芯国际终获ASML大型光刻机

据羊城晚报报道,近日中芯国际从荷兰进口的一台大型光刻机,顺利通过深圳出口加工区场站两道闸口进入厂区,中芯国际发表公告称该光刻机并非此前盛传的EUV光刻机,主要用于企业复工复产后的生产线扩容。 我们知道EUV主要用于7nm及以下制程的芯片制造,光刻机作为集成电路制造中最关键的设备,对芯片制作工艺有着决定性的影响,被誉为“超精密制造技术皇冠上的明珠”,根据之前中芯国际的公报,目...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

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

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

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

百度工程师,获利10万,判刑3年!

所有一夜暴富的方法都写在刑法中,但总有人心存侥幸。这些年互联网犯罪高发,一些工程师高技术犯罪更是引发关注。这两天,一个百度运维工程师的案例传遍朋友圈。1...

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

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

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

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

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

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

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

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

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

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

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

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

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

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

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

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

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

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

正确选择比瞎努力更重要!

字节跳动面试官竟然问了我JDBC?

轻松等回家通知

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

实时更新:计算机编程语言排行榜—TIOBE世界编程语言排行榜(2020年6月份最新版)

内容导航: 1、TIOBE排行榜 2、总榜(2020年6月份) 3、本月前三名 3.1、C 3.2、Java 3.3、Python 4、学习路线图 5、参考地址 1、TIOBE排行榜 TIOBE排行榜是根据全世界互联网上有经验的程序员、课程和第三方厂商的数量,并使用搜索引擎(如Google、Bing、Yahoo!)以及Wikipedia、Amazon、YouTube统计出排名数据。

立即提问
相关内容推荐