μ¨μΌλΈλΌμ°μ μμλ νλμ μ°½μμ μλμ μμ
μ μ λΆ ν μ μλ€
-
Node.js
-
express.js
-
AWS infra(RDS, EC2, SSL, S3)
-
RestFul API
JSON νμμΌλ‘ End Pointμ λΏλ €μ€.
-
var cors = require('cors'); app.use(cors());
λ‘ cors μ€μ -
λ€μ΄λ² μμ΄λλ‘ λ‘κ·ΈμΈ API
config/ ν΄λ μμ± ν, μλμ 4κ° νμΌ
- dbPool.js
var mysql = require('promise-mysql')
const dbConfig = {
host : '',
port : '',
user : '',
password : '',
database : '',
connectionLimit : 20
};
module.exports = mysql.createPool(dbConfig);
- awsConfig.json
{
"accessKeyId": "",
"secretAccessKey" : "",
"region" : "ap-northeast-2"
}
- multer.js
const multer = require('multer');
const multerS3 = require('multer-s3');
const aws = require('aws-sdk');
aws.config.loadFromPath('./config/awsConfig.json');
const s3 = new aws.S3();
const upload = multer({
storage: multerS3({
s3: s3,
bucket: '',
acl: 'public-read',
key: function(req, file, cb) {
cb(null, Date.now() + '.' + file.originalname.split('.').pop());
}
})
});
module.exports = upload;
- secretKey.js
module.exports = {
secret : "(Anykey you want)"
}
git clone https://github.com/Weatherook/server
cd server
npm config package-lock false //package-lock μμ± λͺ»νκ² νμμμ
npm start
integrity checksum failed μ€λ₯κ° λλ κ²½μ° npm cache clean --force μ€ν
μΉμλ² μ μ ν, μ§ν
- sudo apt update -y && sudo apt-get install nginx -y
2. sudo systemctl status nginx
3. sudo systemctl start nginx , sudo systemctl enable nginx
4. Nginx μ€μ νμΌ μμ ```sudo vi /etc/nginx/sites-available/defalut```
server{
listen 8080;
sever_name ip;
location /{
proxy_pass http://ip:ν¬νΈλ²νΈ;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /public{
root /usr/loca/var/www;
}
}
server {
listen 80;
server_name ip;
## redirect http to https ##
rewrite (path μ κ·μ ννμΌλ‘);
}
5. sudo service nginx restart