Here what I have done:
1/ Use Google cloud as a server (Ubuntu 18) for admin page.
2/ Have a project react-js app, ex: abc
3/ Encrypt website www.sub.abc.com successfully, point to IP (Godday domain) on Google cloud successfully. (Source: https://linuxhint.com/redirecting_http_https/).
Problem: My app can not run on port 80, nginx took it! I have search many instructions but they
are not clear.
What I have done to fix this:
1/ Edit config file of nginx (https://www.tecmint.com/change-nginx-port-in-linux/).
2/ Export port 80 in my app. (export port=80 npm start).
Can not run my app on port 80 because something has taken that port?!
If I kill port 80 ===> nginx turn off.
Please give me the right way to change config file or replace nginx default folder to my app folder. Thank you!
I have deployed successfully. If you have the same problem. Can follow this.
DEPLOY
NPM + NODEJS
$ sudo apt-get install curl
$ curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
$ sudo apt-get install nodejs
NGINX
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install nginx
CONFIG
cd /
sudo mkdir app
sudo mkdir api
sudo mkdir html <=== git clone ...
cd /etc/nginx/conf.d
sudo touch api.conf
sudo vi api.conf
you can use the nginx as reverse proxy and change the port of you app for another like 8000 for example and configue in nginx:
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:8000;
}
}
I have deployed successfully.
If you have the same problem. Can follow this.
DEPLOY
`$ sudo apt-get install curl
$ curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
$ sudo apt-get install nodejs`
NGINX
`$ sudo apt update
$ sudo apt upgrade
$ sudo apt install nginx`
CONFIG
`cd /
sudo mkdir app
sudo mkdir api
sudo mkdir html <=== git clone ...
cd /etc/nginx/conf.d
sudo touch api.conf
sudo vi api.conf`
Related
To Begin I have created .net core 6 project with react.js from visual studio 2022.
I have added docker to my project as well.
I have been following this tutorial.
"Quickstart: Use Docker with a React Single-page App in Visual Studio"
https://learn.microsoft.com/en-us/visualstudio/containers/container-tools-react?view=vs-2022
I came to the point where I'm able to build my image however when I'm starting my docker container it is running only my backend api, react app/client is not loading at all.
Any Ideas?
here is how my docker file looks like
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y libpng-dev libjpeg-dev curl libxi6 build-essential libgl1-mesa-glx
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get install -y nodejs
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y libpng-dev libjpeg-dev curl libxi6 build-essential libgl1-mesa-glx
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get install -y nodejs
WORKDIR /src
COPY ["admin_tool_api_ui/admin_tool_api_ui.csproj", "admin_tool_api_ui/"]
RUN dotnet restore "admin_tool_api_ui/admin_tool_api_ui.csproj"
COPY . .
WORKDIR "/src/admin_tool_api_ui"
RUN dotnet build "admin_tool_api_ui.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "admin_tool_api_ui.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "admin_tool_api_ui.dll"]
First of all, I feel your pain. Thanks to Microsoft documentation I'm now a person with high level of patiency, I learned to accept things as they are in life.
Second, I think you are missing the front-end build, which is this piece:
FROM node:16 AS build-web
COPY ./admin_tool_api_ui/ClientApp/package.json /admin_tool_api_ui/ClientApp/package.json
COPY ./admin_tool_api_ui/ClientApp/package-lock.json /admin_tool_api_ui/ClientApp/package-lock.json
WORKDIR /admin_tool_api_ui/ClientApp
RUN npm ci
COPY ./admin_tool_api_ui/ClientApp/ /admin_tool_api_ui/ClientApp
RUN npm run build
So your final Dockerfile can be something like this:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y libpng-dev libjpeg-dev curl libxi6 build-essential libgl1-mesa-glx
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get install -y nodejs
WORKDIR /src
COPY ["admin_tool_api_ui/admin_tool_api_ui.csproj", "admin_tool_api_ui/"]
RUN dotnet restore "admin_tool_api_ui/admin_tool_api_ui.csproj"
COPY . .
WORKDIR "/src/admin_tool_api_ui"
RUN dotnet build "admin_tool_api_ui.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "admin_tool_api_ui.csproj" -c Release -o /app/publish
FROM node:16 AS build-web
COPY ./admin_tool_api_ui/ClientApp/package.json /admin_tool_api_ui/ClientApp/package.json
COPY ./admin_tool_api_ui/ClientApp/package-lock.json /admin_tool_api_ui/ClientApp/package-lock.json
WORKDIR /admin_tool_api_ui/ClientApp
RUN npm ci
COPY ./admin_tool_api_ui/ClientApp/ /admin_tool_api_ui/ClientApp
RUN npm run build
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
COPY --from=build-web /admin_tool_api_ui/ClientApp/build ./ClientApp/build
ENTRYPOINT ["dotnet", "admin_tool_api_ui.dll"]
I just set property "Copy to Output directory" = "Copy always" for all React related files ClientApp directory hierarchy via "Properties" dialog.
I have setup Solr in Docker Container below is the Dockerfile
FROM ubuntu
RUN apt update -y && apt install wget -y && apt install curl -y && apt install openjdk-11-jdk -y
RUN cd /opt && wget https://archive.apache.org/dist/lucene/solr/8.3.1/solr-8.3.1.tgz && tar xzf solr-8.3.1.tgz solr-8.3.1/bin/install_solr_service.sh --strip-components=2 && bash ./install_solr_service.sh solr-8.3.1.tgz
COPY ssl /ssl
COPY solr.in.sh /etc/default/solr.in.sh
USER solr
EXPOSE 8983
WORKDIR /opt/solr
CMD ["bin/solr", "start", "-f"]
This is a basic Solr
container. Now I want it to run using SSL certificate.
How do I do it?
Not much help from the official Solr website
After the pulling the SQL Server's container, when I want to run it, Docker shows me "exited" status when O execute this command:
docker ps -a
I tried this link but it did not help me:
https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-configure-docker?view=sql-server-ver15#troubleshooting
These are my container logs:
https://paste.fedoraproject.org/paste/dBBFlyulZ1Bera2caa84tA
I using Fedora 29 x86_x64 and my Docker client version is 18.09.6 Build 481bc77 and Docker-Ce is 19.03.4
(Sorry for my bad English)
This is because starting SQL-Server produces an error.
The error can be looked up in the error log.
Unfortunately, you can't access it, becaus the container terminates.
To lookup the error log, you need to have shared that directory...
On the host, create the location where the container stores the data:
sudo mkdir -p /var/opt/mssql
Create the docker-container with the data directory mapped:
docker pull mcr.microsoft.com/mssql/server:2017-latest
docker run -d -p 2017:1433 --name mssql_2017 -e MSSQL_SA_PASSWORD=TOP_SECRET -e ACCEPT_EULA=Y -e MSSQL_PID="Developer" -v /var/opt/mssql:/var/opt/mssql -d mcr.microsoft.com/mssql/server:2017-latest
(note: this maps port 1433 int he container to port 2017 on the host)
then, to start/stop the container:
docker start mssql_2017
docker stop mssql_2017
Now you can now look at the errors in /var/opt/mssql/log on your host machine.
Also, you can check if it works by connecting with sqlcmd:
For Fedora:
sudo su
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo
exit
sudo yum clean expire-cache
sudo yum check-update
sudo yum remove mssql-tools unixODBC-utf16-devel
sudo yum install mssql-tools unixODBC-devel
sudo ln -sfn /opt/mssql-tools/bin/sqlcmd /usr/bin/sqlcmd
sqlcmd -S localhost,2017 -U SA -P "<YourPassword>"
For Ubuntu:
sudo wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)"
sudo apt-get update
sudo apt-get install mssql-tools
sudo ln -sfn /opt/mssql-tools/bin/sqlcmd /usr/bin/sqlcmd
sqlcmd -S localhost,2017 -U SA -P "<YourPassword>"
I have created the production build using
npm run build
After creating of successful build I have run the command
serve -s build
how can i start my application on production server in detach mode or in background mode. It is working in my local fine.
Finally I got the solution to start the react application or build of application on nginx server
We’ll need to install node to get working with our React app. The following will do the job to get the latest version of Node at the time of running.
sudo apt-get update
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential
This installs Node, npm, and the build tools that come in handy for npm.
Once Node & npm are installed, we’re going to need to install two tools:
Clone your repository on your machine
sudo mkdir /var/www
cd /var/www/
Take the clone or paste the code in the current directory, then change the directory.
cd sample-app
Install the project on the system.
sudo npm install
The You need to create the optimized production build of the project
sudo npm run build
Install and Configure Nginx to serve your application
sudo apt-get install nginx
sudo nano /etc/nginx/sites-available/default
and paste the below code
server {
listen 80 default_server;
root /var/www/sample-app/build;
server_name localhost;
index index.html index.htm;
error_page 404 /;
location / {
}
}
Now you need to start your server
sudo service nginx start
i try to install Apache 2 on my Ubuntu system version is 14.04 LTS,
installation was success full but when i try to restart the Apache its showing unrecognized service , please help me to solve this problem.
Thanks in advance.
To start the apache server, you can use this command:
$ sudo service httpd start
Other available commands are as follows:
$ sudo service httpd restart ## restart the apache server
$ sudo service httpd stop ## stop the server
To list all httpd commands:
$ sudo service httpd
sudo apt-get remove --purge apache2 apache2-utils
sudo apt-get install --reinstall apache2 apache2-utils
sudo service apache2 start
and then check by:
sudo service apache2 status
I faced same problem and solved it by running the following command:
sudo apt-get purge apache2 apache2-utils apache2.2-bin
sudo apt-get autoremove
sudo apt-get install apache2 apache2-utils apache2.2-bin