B
B
bova2018-11-12 10:18:14
Nginx
bova, 2018-11-12 10:18:14

How to fix "301 Moved Permanently" error on nginx (docker)?

Good afternoon,
please help me with a question on nginx in which I am a complete zero.
I'm trying to deploy nginx via docker so that I can later use it to upload files, but for some reason it doesn't work.

Dockerfile
FROM nginx
COPY static-html-directory /usr/share/nginx/html
COPY static-html-directory/oam /usr/share/nginx/oam
COPY nginx.conf /usr/share/nginx/nginx.conf

nginx.conf
worker_processes  1;

error_log  /var/log/nginx/error.log debug;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


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

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
    server {
        listen       80;
        server_name  0.0.0.0;

        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        }
        location /oam {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        }
    }

}


after deploy
docker build -t some-content-nginx .
docker run -p 80:80 some-content-nginx I do curl -X POST
myhostip /oam and get 301 Moved Permanently

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
ISE73, 2018-11-12
@ISE73

The problem is in the Nginx config.
"location /oam" around here somewhere ;)

V
vreitech, 2018-11-12
@fzfx

and if you change the value of server_name to _?

S
scor2k, 2018-11-22
@scor2k

What are you trying to POST to index.html to send? How are you going to process it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question