Skip to content

Commit

Permalink
nginx successfull configured
Browse files Browse the repository at this point in the history
  • Loading branch information
abinth11 committed Aug 3, 2023
1 parent b704e24 commit 2e5401d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 26 deletions.
2 changes: 1 addition & 1 deletion client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN rm -rf /usr/share/nginx/html/*
# Copy the built React app from the build stage
COPY --from=build /usr/src/reactapp/build /usr/share/nginx/html

EXPOSE 3000
EXPOSE 80

# Start nginx server
CMD ["nginx", "-g", "daemon off;"]
2 changes: 1 addition & 1 deletion client/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ const CONFIG_KEYS = {
GOOGLE_AUTH_CLIENT_ID: process.env.REACT_APP_CLIENT_ID as string,
STRIPE_PUBLISHABLE_KEY: process.env.REACT_APP_STRIPE_PUBLISHABLE_KEY as string,
REDIRECT_URI: process.env.REACT_APP_REDIRECT_URI as string,
API_BASE_URL: "http://tutortrek.online",
API_BASE_URL: process.env.API_BASE_URL as string,
};
export default CONFIG_KEYS;
16 changes: 8 additions & 8 deletions conf.d/tutortrek.online.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ upstream backend {

server {
listen 80;
server_name tutortrek.online;
server_name localhost; # Use a dummy value for testing

location / {
root /usr/share/nginx/html;
index index.html;

try_files $uri $uri/ /index.html;
root /usr/share/nginx/html;
index index.html;
# Other config you desire (TLS, logging, etc)...
try_files $uri /index.html;
}

location /api {
proxy_pass http://backend;
proxy_pass http://backend; # Load balancing for server
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;
}

location /static {
alias /usr/share/nginx/html;
location /static {
alias /usr/share/nginx/html/static; # Add the /static path
}
}
25 changes: 9 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@ services:
dockerfile: Dockerfile
image: abin11/tutortrek_client:latest
container_name: tutortrek_client
ports:
- "3000:3000"
#volumes:
#- static_files:/usr/share/nginx/html/static # Mount the volume to serve static files
#- ./client/build:/usr/src/reactapp/build # Mount the React build directory to the volume
volumes:
- ./client/build:/usr/src/reactapp/build
env_file:
- ./client/.env
depends_on:
- server
networks:
- connection_network
- tutortrek_connection_network
deploy:
resources:
limits:
Expand All @@ -34,7 +31,7 @@ services:
depends_on:
- redis
networks:
- connection_network
- tutortrek_connection_network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4000/health"]
interval: 30s
Expand All @@ -52,27 +49,23 @@ services:
- ./.db:/data
restart: always
networks:
- connection_network
- tutortrek_connection_network

nginx:
image: nginx:alpine
volumes:
- ./conf.d:/etc/nginx/conf.d
#- static_files:/usr/share/nginx/html/static # Mount the volume to serve static files
#- /path/to/your/ssl/certs:/etc/nginx/ssl # Add this line
- ./client/build:/usr/share/nginx/html # Mount the complete React build directory
- ./client/build:/usr/share/nginx/html
depends_on:
- server
- client
ports:
- "80:80"
- "4000:80" # Expose Nginx's port 80 to host port 4000
- "443:443"
networks:
- connection_network
- tutortrek_connection_network

networks:
connection_network:
tutortrek_connection_network:
driver: bridge

volumes:
static_files: # Define the static_files volume

0 comments on commit 2e5401d

Please sign in to comment.