1

I've one folder index.html file and inside that folder, I have another one with own index.html

folders structure

I am using this config

    events {
  worker_connections  2048;
}

http {
    server {
      listen  6666;
      server_name  0.0.0.0;
      root /static;
      index index.html;
      charset utf-8;

        location / {
                include  /etc/nginx/mime.types;
                types  {font/truetype ttf;}
                types  {application/font-woff2 woff2;}
        }

        location /test {
            alias /static/test;
        }
    }
}

Nginx is run under docker container

There is my docker-compose

version: '2'
services:
  serve_site:
    container_name: server
    build:
      context: .
      dockerfile: ./docker/Dockerfile-nginx
    volumes:
      - ./www-public:/static
    ports:
      - "80:6666"

And Dockerfile

FROM nginx:alpine
MAINTAINER Viktor Dzundza <victor.dzundza.dev@gmail.com>
ENV REFRESHED_AT 20170112:000001
ENV HOME=/static
RUN mkdir $HOME
COPY ./www-public $HOME/
WORKDIR $HOME
COPY nginx.conf /etc/nginx/nginx.conf

RUN set -x ; \
  addgroup -g 82 -S www-data ; \
  adduser -u 82 -D -S -G www-data www-data && exit 0 ; exit 1

RUN chown -R www-data:www-data /static/*
RUN chmod -R 0755 /static/*


CMD ["nginx", "-g", "daemon off;"]

But I think that problem with nginx configuration.

When I am trying to go localhost/test the browser is redirected to the localhost:6666/test

How can I configure nginx for solving this issue?

Viktor
  • 121
  • 5
  • Please explain why this is a problem. `nginx` is listening on port 6666, so `localhost:6666/test` is the correct URL for the browser. Maybe add the config parts you left out. Also, explain why you think you would need to handle `/test` any different to begin with. – Sven Feb 19 '17 at 11:42
  • @Sven Ohh, I forgot write that I am using docker – Viktor Feb 19 '17 at 11:45
  • 1
    How is this relevant? Give us the complete picture... – Sven Feb 19 '17 at 11:46
  • @Sven updated the question – Viktor Feb 19 '17 at 11:47
  • What is the complete nginx configuration? You are only showing the part for port 6666, and no information about the standard HTTP port 80. – Tero Kilkanen Feb 19 '17 at 14:59
  • Have you tried: [`port_in_redirect off;`](http://nginx.org/en/docs/http/ngx_http_core_module.html#port_in_redirect)? – Richard Smith Feb 19 '17 at 23:20

0 Answers0