Reputation: 21
I am trying to link a domain I purchased to my Google Cloud service, using docker a Nginx but, I have try so many solution write on Stackoverflow... but all failed.
What did I miss... Do you have any idea ? There is my files
Environnement
Domain : Google domain Server : Google Cloud Service / compute engine / Centos 7.0; Container : Docker / Docker-compose / Nginx
Dockerfile
FROM nginx WORKDIR /usr/share/nginx/html COPY ./client/dist ./ COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]
docker-compose
app: build: context: . dockerfile: ./Dockerfile environment: - NODE_ENV=prod - PORT=8081 volumes: - /usr/share/nginx/html ports: - "8081:80"
Nginx
server {
listen 80;
server_name example.net;
root /usr/share/nginx/html;
index index.html;
charset utf-8;
# enable gzip
gzip on;
gzip_disable "msie6";
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types
text/plain
text/css
text/js
text/xml
text/javascript
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
image/svg+xml;
location ~* ^.+\.(ico|gif|jpg|jpeg|png)$ {
expires 30d;
}
location ~* ^.+\.(css|js|txt|xml|swf|wav)$ {
expires 24h;
}
location ~* ^.+\.(html|htm)$ {
expires 1h;
}
location ~* ^.+\.(eot|ttf|otf|woff|svg)$ {
expires max;
}
location / {
proxy_pass http://localhost:8081;
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-Proto $scheme;
proxy_read_timeout 1800;
proxy_connect_timeout 1800;
try_files $uri /index.html;
}
}
Google Cloud Firewall
Google Cloud Firewall Port Image
I have a domain I have purchased (ex. example.net) and I have an VueJs app running on port 8081. My application is working on example.net:8081... But I want it running only on example.net... But nothing...
Hope some will find where I am making a mistake...
Thank you for reading
PS : There is some people who will tell me this is probably a duplicate post but... 1. I do not find any good anwser to this, I would not ask for help I would find it. 2. Don't be mean please).
Upvotes: 0
Views: 697
Reputation: 3427
8081:80
you current bind container port 80 to 8081
on your server machine. But you want access to your domain without port, right ? So, bind 80 port
inside container to 80 port
on serrver by change 8081:80
to 80:80
.
And make sure theris nothing use 80 port
on real serve machine by command:
sudo lsof -i tcp:80
Upvotes: 1