各位大佬们 我使用docker部署完成后 域名访问得加端口号才能访问,请问这个如何解决?

nginx配置

    listen       80;
    server_name  0.0.0.0;
    root   /var/www/html/public;
    index  index.php index.html index.htm;

    client_header_buffer_size 4069k;
    large_client_header_buffers 4 128k;
    client_max_body_size 2048m;

    sendfile   on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 180;
    fastcgi_connect_timeout 180s;
    fastcgi_send_timeout 600s;
    fastcgi_read_timeout 600s;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 8 128k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 256k;
    fastcgi_intercept_errors on;

    gzip on;
    gzip_min_length 1k;
    gzip_buffers     4 32k;
    gzip_http_version 1.1;
    gzip_comp_level 6;
    gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
    gzip_vary on;
    gzip_proxied   expired no-cache no-store private auth;
    gzip_disable   "MSIE [1-6]\.";

    location / {
        index index.html index.php error/index.html;
        if (!-f $request_filename)
        {
            rewrite  ^(.*)$  /index.php?s=$1 last;
        }
    }

      # 自定义地图服务代理
      location /_AMapService/v4/map/styles {
        set $args "$args&jscode=05dcf3176750d9bcbd33503ae2d2e3d9";
        proxy_pass https://webapi.amap.com/v4/map/styles;
      }
      # 海外地图服务代理
      location /_AMapService/v3/vectormap {
        set $args "$args&jscode=05dcf3176750d9bcbd33503ae2d2e3d9";
        proxy_pass https://fmap01.amap.com/v3/vectormap;
      }
      # Web服务API 代理
      location /_AMapService/ {
        set $args "$args&jscode=05dcf3176750d9bcbd33503ae2d2e3d9";
        proxy_pass https://restapi.amap.com/;
      }

    location ~ \.php(.*)$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PATH_INFO  $fastcgi_path_info;
        fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
        include        fastcgi_params;
    }
}

nging.fonf配置

worker_processes auto;
worker_rlimit_nofile 65535;

pid /run/nginx.pid;
error_log /var/log/nginx/error.log;
include /etc/nginx/modules-enabled/*.conf;

events {
        use epoll;
        worker_connections 65535;
        multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

dockerfile配置

RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/' /etc/apt/sources.list.d/debian.sources \
    && sed -i 's/security.debian.org/mirrors.aliyun.com/' /etc/apt/sources.list.d/debian.sources \
    && apt-get update && apt-get install -y \
    nginx \
    libmcrypt-dev \
    zlib1g-dev \
    libzip-dev \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install gd bcmath \
    && docker-php-ext-install pcntl calendar \
    && docker-php-ext-configure pcntl --enable-pcntl \
    && docker-php-ext-configure opcache --enable-opcache && docker-php-ext-install opcache \
    && docker-php-ext-install pdo_mysql zip \
    && pecl install grpc && docker-php-ext-enable grpc \
    && pecl install protobuf && docker-php-ext-enable protobuf \
    && pecl install redis && docker-php-ext-enable redis \
    && pecl install mcrypt && docker-php-ext-enable mcrypt \
    && apt-get purge -y --auto-remove \
    && rm -rf /var/cache/apt/* \
    && rm -rf /var/lib/apt/lists/* \
    && rm -rf /pecl

# 项目文件上传, 把当前目录下的所有文件上传到 /var/www/html 目录下
COPY . /var/www/html/
COPY docker/upload.ini /usr/local/etc/php/conf.d/
COPY docker/default.conf /etc/nginx/sites-enabled/default
COPY docker/nginx.conf /etc/nginx/nginx.conf
COPY docker/www.conf /usr/local/etc/php-fpm.d/

WORKDIR /var/www/html

EXPOSE 80

CMD php-fpm -D && nginx -g 'daemon off;'

docker

使用域名访问

使用端口访问

求助各位大佬 这个端口号改如何去掉 还有这个index.html#如何去掉

已采纳
YANG001
YANG001
这家伙很懒,什么也没写~
1天前

你这架构和描述有点复杂,涉及多也就难以排查,不过咋一看

直接80:80即可

阿水丶
阿水丶回复YANG001
这家伙很懒,什么也没写~
1天前

我是使用docker的nginx操作的

这里有80端口 我好多本地项目

1个回答默认排序 投票数排序
阿水丶
阿水丶
这家伙很懒,什么也没写~
1天前

各位大佬 我已经解决了!感谢关注

请先登录
0
1
0
3