Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NGINX support #25

Closed
Yetangitu opened this issue Jun 1, 2017 · 7 comments
Closed

NGINX support #25

Yetangitu opened this issue Jun 1, 2017 · 7 comments

Comments

@Yetangitu
Copy link
Contributor

FYI,

There is no need for the hard dependency on Apache, it can be made to work with other servers as well. Currently the install does not work due to the use of the Apache-specific 'apache_get_modules()' in 'modRewriteEnabled()' so those who want to use another server should edit that function to make it conditional on the presence of Apache:

function modRewriteEnabled() {
    if (isApache()) {
        return in_array('mod_rewrite', apache_get_modules());
    } else {
        return false;
    }
}

Since nginx does not support .htaccess files you'll need to rewrite the rewrite-rules to nginx' version of mod_rewrite. The following works for me:

    location / {
    rewrite ^/$ /view/ last;
    }
    location /bootstrap {
    rewrite ^/bootstrap/(.+)$ /view/bootstrap/$1 last;
    }
    location /js {
    rewrite ^/js/(.+)$ /view/js/$1 last;
    }
    location /css {
    rewrite ^/css/(.+)$ /view/css/$1 last;
    }
    location /img {
    rewrite ^/img/(.+)$ /view/img/$1 last;
    }
    location /page {
    rewrite ^/page/([0-9]+)/?$ /view/?page=$1 last;
    }
    location /videoOnly {
    rewrite ^/videoOnly/?$ /view/?type=video last;
    }
    location /audioOnly {
    rewrite ^/audioOnly/?$ /view/?type=audio last;
    }
    location = /download {
    rewrite ^(.*)$ /view/downloadExternalVideo.php last;
    }
    location = /downloadNow {
    rewrite ^(.*)$ /objects/downloadVideo.php last;
    }
    location = /getDownloadProgress {
    rewrite ^(.*)$ /objects/downloadVideoProgress.php last;
    }
    location = /about {
    rewrite ^(.*)$ /view/about.php last;
    }
    location = /contact {
    rewrite ^(.*)$ /view/contact.php last;
    }
    location = /sendEmail {
    rewrite ^(.*)$ /objects/sendEmail.json.php last;
    }
    location = /captcha {
    rewrite ^(.*)$ /objects/getCaptcha.php last;
    }
    location /monitor {
    rewrite ^/monitor/(.+)$ /objects/ServerMonitor/$1 last;
    }
    location /cat {
    rewrite ^/cat/([A-Za-z0-9-]+)/?$ /view/?catName=$1 last;
    }
    location /video {
    rewrite ^/video/([A-Za-z0-9-_.]+)/?$ /view/?videoName=$1 last;
    }
    location /videoEmbeded {
    rewrite ^/videoEmbeded/([A-Za-z0-9-_.]+)/?$ /view/videoEmbeded.php?videoName=$1 last;
    }
    location = /upload {
    rewrite ^(.*)$ /view/mini-upload-form/ last;
    }
    location = /fileUpload {
    rewrite ^(.*)$ /view/mini-upload-form/upload.php last;
    }
    location /uploadStatu {
    rewrite ^/uploadStatus /view/mini-upload-form/videoConversionStatus.php last;
    }
    location = /user {
    rewrite ^(.*)$ /view/user.php last;
    }
    location = /users {
    rewrite ^(.*)$ /view/managerUsers.php last;
    }
    location = /users.json {
    rewrite ^(.*)$ /objects/users.json.php last;
    }
    location = /updateUser {
    rewrite ^(.*)$ /objects/userUpdate.json.php last;
    }
    location = /savePhoto {
    rewrite ^(.*)$ /objects/userSavePhoto.php last;
    }
    location = /addNewUser {
    rewrite ^(.*)$ /objects/userAddNew.json.php last;
    }
    location = /deleteUser {
    rewrite ^(.*)$ /objects/userDelete.json.php last;
    }
    location = /recoverPass {
    rewrite ^(.*)$ /objects/userRecoverPass.php last;
    }
    location = /saveRecoverPassword {
    rewrite ^(.*)$ /objects/userRecoverPassSave.json.php last;
    }
    location = /signUp {
    rewrite ^(.*)$ /view/signUp.php last;
    }
    location = /createUser {
    rewrite ^(.*)$ /objects/userCreate.json.php last;
    }
    location = /usersGroups {
    rewrite ^(.*)$ /view/managerUsersGroups.php last;
    }
    location = /usersGroups.json {
    rewrite ^(.*)$ /objects/usersGroups.json.php last;
    }
    location = /addNewUserGroups {
    rewrite ^(.*)$ /objects/userGroupsAddNew.json.php last;
    }
    location = /deleteUserGroups {
    rewrite ^(.*)$ /objects/userGroupsDelete.json.php last;
    }
    location = /ads {
    rewrite ^(.*)$ /view/managerAds.php last;
    }
    location = /addNewAd {
    rewrite ^(.*)$ /objects/video_adsAddNew.json.php last;
    }
    location = /ads.json {
    rewrite ^(.*)$ /objects/video_ads.json.php last;
    }
    location = /deleteVideoAd {
    rewrite ^(.*)$ /objects/video_adDelete.json.php last;
    }
    location /adClickLo {
    rewrite ^/adClickLog /objects/video_adClickLog.php last;
    }
    location = /categories {
    rewrite ^(.*)$ /view/managerCategories.php last;
    }
    location = /categories.json {
    rewrite ^(.*)$ /objects/categories.json.php last;
    }
    location = /addNewCategory {
    rewrite ^(.*)$ /objects/categoryAddNew.json.php last;
    }
    location = /deleteCategory {
    rewrite ^(.*)$ /objects/categoryDelete.json.php last;
    }
    location = /orphanFiles {
    rewrite ^(.*)$ /view/orphanFiles.php last;
    }
    location = /mvideos {
    rewrite ^(.*)$ /view/managerVideos.php last;
    }
    location = /videos.json {
    rewrite ^(.*)$ /objects/videos.json.php last;
    }
    location = /deleteVideo {
    rewrite ^(.*)$ /objects/videoDelete.json.php last;
    }
    location = /addNewVideo {
    rewrite ^(.*)$ /objects/videoAddNew.json.php last;
    }
    location = /refreshVideo {
    rewrite ^(.*)$ /objects/videoRefresh.json.php last;
    }
    location = /setStatusVideo {
    rewrite ^(.*)$ /objects/videoStatus.json.php last;
    }
    location = /reencodeVideo {
    rewrite ^(.*)$ /objects/videoReencode.json.php last;
    }
    location = /addViewCountVideo {
    rewrite ^(.*)$ /objects/videoAddViewCount.json.php last;
    }
    location = /saveComment {
    rewrite ^(.*)$ /objects/commentAddNew.json.php last;
    }
    location /comments {
    rewrite ^/comments.json/([0-9]+)$ /objects/comments.json.php?video_id=$1 last;
    }
    location = /login {
    rewrite ^(.*)$ /objects/login.json.php last;
    }
    location = /logoff {
    rewrite ^(.*)$ /objects/logoff.php last;
    }
    location = /like {
    rewrite ^(.*)$ /objects/like.json.php?like=1 last;
    }
    location = /dislike {
    rewrite ^(.*)$ /objects/like.json.php?like=-1 last;
    }
    location /update {
    rewrite ^/update/?$ /update/update.php last;
    }
    location = /siteConfigurations {
    rewrite ^(.*)$ /view/configurations.php last;
    }
    location = /updateConfig {
    rewrite ^(.*)$ /objects/configurationUpdate.json.php last;
    }
    location = /charts {
    rewrite ^(.*)$ /view/charts.php last;
    }

Here's an example config for nginx, you'll need to edit it to set the server_name, location of SSL certificates and such. You also might need to edit some security-related headers if you want your site to be usable in iframes.

example_config_for_nginx.txt

@DanielnetoDotCom
Copy link
Member

Wow!, very thanks about it.
If you can give us more details about install it on nginx, will be great.

@Yetangitu
Copy link
Contributor Author

Yetangitu commented Jun 1, 2017

I can do a pull request for some changes to make it nginx-compatible. It will probably work with Lighttpd as well with the same pre-condition of rewriting the rewrite-rules to its syntax. I'll do some more testing and report back.

@DanielnetoDotCom
Copy link
Member

DanielnetoDotCom commented Jun 1, 2017

Very Nice, it will be great. thanks for your help.
Fell free to ask any help if you need

@gamersalpha
Copy link

hello there,

how install this files please ?

@XxTWMLxX
Copy link

where do you change the first part, the dependency on Apache to allow nginx?
what filename do i need to edit.

@polfejs
Copy link

polfejs commented Jun 24, 2019

yes, what file name to edit? Is there any documentation step-by-step how to install on nginx ?

Bests

@DanielnetoDotCom
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants